Skip to content

feat: add metadata support to role markers in dotprompt#563

Open
pavelgj wants to merge 6 commits intomainfrom
pj/metadata
Open

feat: add metadata support to role markers in dotprompt#563
pavelgj wants to merge 6 commits intomainfrom
pj/metadata

Conversation

@pavelgj
Copy link
Copy Markdown
Collaborator

@pavelgj pavelgj commented May 2, 2026

Adds metadata support to the role helper.

Allow the {{role}} helper to carry key-value metadata via Handlebars hash arguments:

{{role "user" purpose="preamble" cacheTo="here"}}

This lets prompt authors annotate message boundaries with arbitrary metadata (e.g., marking a message's purpose for downstream consumers or signaling cache breakpoints) without changing the message content itself. The metadata is encoded into the existing role marker format, parsed during message splitting, and surfaced on the Message.metadata field.

Implemented across JS, Go, and Dart with shared spec tests in spec/helpers/role_metadata.yaml.

Also pins 6 vulnerable Python transitive dependencies (nbconvert, pytest, requests, tornado, pygments, uv) to patched versions and regenerates the lock/requirements files... just to make python presubmits pass.

Extend the `role` helper to accept key-value metadata pairs via
Handlebars hash arguments (e.g., `{{role "user" purpose="preamble"}}`).
Update the role marker format, regex, and parsing logic to encode,
split, and extract metadata. Propagate parsed metadata into message
objects via a new optional `metadata` field on messages.
@pavelgj pavelgj requested a review from mbleigh May 2, 2026 01:59
@github-actions github-actions Bot added the js label May 2, 2026
@pavelgj pavelgj changed the title feat: add metadata support to role markers in dotprompt feat(js): add metadata support to role markers in dotprompt May 2, 2026
@pavelgj pavelgj changed the title feat(js): add metadata support to role markers in dotprompt feat: add metadata support to role markers in dotprompt May 2, 2026
Add support for passing key=value metadata to the `{{role}}` Handlebars
helper (e.g. `{{role "user" purpose="preamble"}}`). The metadata is
encoded into the role marker string, parsed back during message
construction, and stored in a new `Metadata` field on `Message`. Updates
the regex, adds `parseRoleMarker`, and includes spec tests.
@github-actions github-actions Bot added the go label May 2, 2026
Add support for passing metadata via hash parameters in the `{{role}}`
helper (e.g. `{{role "user" purpose="preamble"}}`). Metadata key-value
pairs are serialized into the role marker, parsed during message
construction, and attached to the resulting Message object. Also adds
spec test assertions for metadata on messages.
…bilities

Add and update constraint dependencies to fix multiple security
advisories including vulnerabilities in nbconvert, pytest, requests,
tornado, pygments, and uv. Remove resolved advisory from pysentry
while_no_fix ignore list.
@github-actions github-actions Bot added the python label May 2, 2026
Remove `-e` editable install entries for `dotpromptz` and `handlebarrz`
from the exported requirements.txt, keeping only the dependency
comments for workspace resolution.
@pavelgj
Copy link
Copy Markdown
Collaborator Author

pavelgj commented May 2, 2026

cc @apascal07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant