Skip to content

feat(py): system_prompt_data() for the source-derived prompt fields - #309

Merged
jat255 merged 3 commits into
jat255/g9yd-agent-helpersfrom
jat255/6fv1-prompt-data
Sep 8, 2026
Merged

feat(py): system_prompt_data() for the source-derived prompt fields#309
jat255 merged 3 commits into
jat255/g9yd-agent-helpersfrom
jat255/6fv1-prompt-data

Conversation

@jat255

@jat255 jat255 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Builds the mapping the system prompt template renders against. #304 landed the renderer and the tool-derived fields. This adds the fields that need a data source, so #311 has something to render.

Implementation

system_prompt_data() produces the same 25 keys, in the same order, as its R counterpart.

Also fixed an issue discovered during implementation where python collapsed every run of whitespace where R collapses only whitespace around a newline. The fix is in the shared helper, with a fixture case for authored inline spacing.

Also removed run_r out of the shared template (which doesn't make sense in the Python case, so the two can't share the same language, since Python's execution tool is run_python). The template now substitutes {{ execution_tool }} and gates all three mentions on a neutral has_execution_tool. Each package maps its own tool name onto the flag and carries the name in the mapping as execution_tool. R's rendered prompt is unchanged: its agent always registers run_r.

Tests

A new shared fixture pins the mapping for 13 source shapes.

Verified: ruff check, pyrefly check src tests, pytest (1058 passing), and the two touched R test files under the framework R with pkgload::load_all(). The full R suite was not run locally.

Accepted difference

A dictionary with an empty description produces a stray ## Name heading in R and nothing in Python. Not pinned: the input is rare and the Python result is safe.

R changes

@simonpcouch

R source changes are the execution-tool rename only: citations.R maps this package's run_r onto the {{ execution_tool }}, and prompt.R adds execution_tool to the mapping. Otherwise R gains the runner for the new fixture in test-prompt.R and the synced fixture copies.

There is no behavior delta in R and no call site changes.

One hand-written R test was deleted and replaced with the fixture version (system prompt data contains facts and runtime content)

@jat255 jat255 added this to the py-M5: agent, tools, and prompt milestone Sep 7, 2026
@jat255 jat255 added r Affects the R implementation py Affects the Python implementation needs-manual-review Agent-created work that needs a human review labels Sep 7, 2026
@jat255
jat255 force-pushed the jat255/6fv1-prompt-data branch from 1178b43 to 1f73c16 Compare September 7, 2026 20:57
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Preview deployed to Connect (dogfood.team.pct.posit.it): https://dogfood.team.pct.posit.it/connect/#/apps/d7a36cae-8f27-448b-a478-61b81fbe3942/draft/368843

Deployed from commit 7eb0183.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Preview deployed to Connect (connect.staging.pct.posit.it): https://connect.staging.pct.posit.it/connect/#/apps/ad662e1b-5048-4acc-9ad7-f9478c92274e/draft/2687

Deployed from commit 7eb0183.

@jat255 jat255 removed the needs-manual-review Agent-created work that needs a human review label Sep 8, 2026
@jat255
jat255 requested a review from simonpcouch September 8, 2026 04:29
@jat255
jat255 marked this pull request as ready for review September 8, 2026 04:40
Builds the mapping the system prompt template is rendered against:
the table listing, dictionary and glossary prose, the definition index
and its completeness flags, the catalog-search and multi-source flags,
the per-tool citation flags, and the instructions.

tests/shared/prompt-data.json pins the mapping for a set of source
shapes and both suites hydrate its descriptors into real in-process
DuckDB sources, so prompt-render.json's rendering contract now has an
authority for its input as well as its output. The R suite's
hand-written field-set assertion is replaced by the fixture's, which
both packages check.
A dictionary's inline rendering collapsed every run of whitespace, so a
glossary body, relationship description, or column fact authored with
repeated spaces reached the model differently in each package. Narrow it
to newlines and the whitespace around them, which is what pkg-r does and
what the definition registry already did, and pin a glossary body with
inline spacing in the shared prompt-data cases.
The template hardcoded run_r: two "How to answer" sentences named it
unconditionally, and the citation bullet gated on has_run_r, a flag only
a tool literally named run_r could earn. Python's execution tool is
run_python, so a Python agent would have been told to call a tool it
does not have.

The template now substitutes {{ execution_tool }} and gates all three
mentions on a neutral has_execution_tool flag. Each package maps its own
tool name onto the flag and carries the name in the prompt data. The
fixtures pin the per-language names as substitutions and a
$execution_tool token in tools lists, so neither fixture picks a
language. R's rendered prompt is unchanged: its agent always registers
run_r.
@jat255
jat255 force-pushed the jat255/6fv1-prompt-data branch from 6012fc2 to 7eb0183 Compare September 8, 2026 04:40
@jat255
jat255 merged commit f812b17 into main Sep 8, 2026
13 checks passed
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Cleaned up 3 preview bundle(s) on https://dogfood.team.pct.posit.it: 368628, 368838, 368843

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Cleaned up 3 preview bundle(s) on https://connect.staging.pct.posit.it: 2683, 2684, 2687

@jat255
jat255 deleted the jat255/6fv1-prompt-data branch September 8, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

py Affects the Python implementation r Affects the R implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants