feat(py): system_prompt_data() for the source-derived prompt fields - #309
Merged
Conversation
jat255
force-pushed
the
jat255/6fv1-prompt-data
branch
from
September 7, 2026 20:57
1178b43 to
1f73c16
Compare
|
Preview deployed to Connect ( Deployed from commit 7eb0183. |
|
Preview deployed to Connect ( Deployed from commit 7eb0183. |
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
force-pushed
the
jat255/6fv1-prompt-data
branch
from
September 8, 2026 04:40
6012fc2 to
7eb0183
Compare
simonpcouch
approved these changes
Sep 8, 2026
|
Cleaned up 3 preview bundle(s) on https://dogfood.team.pct.posit.it: 368628, 368838, 368843 |
|
Cleaned up 3 preview bundle(s) on https://connect.staging.pct.posit.it: 2683, 2684, 2687 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_rout 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 isrun_python). The template now substitutes{{ execution_tool }}and gates all three mentions on a neutralhas_execution_tool. Each package maps its own tool name onto the flag and carries the name in the mapping asexecution_tool. R's rendered prompt is unchanged: its agent always registersrun_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 withpkgload::load_all(). The full R suite was not run locally.Accepted difference
A dictionary with an empty
descriptionproduces a stray## Nameheading 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.Rmaps this package'srun_ronto the{{ execution_tool }}, andprompt.Raddsexecution_toolto the mapping. Otherwise R gains the runner for the new fixture intest-prompt.Rand 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)