Repository navigation
feat: dynamic context sections in the default system prompt - #114
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
Fresh default-path sessions pin a one-line Context section (working directory + today's UTC date, civil-from-days) after the incumbent prompt — removes a whole class of clock/cwd probing turns at zero runtime cost. Extracted civil_from_days() from fmt_mtime() (shared Hinnant algorithm); explicit --system / TOLE_SYSTEM_PROMPT still win; the assembled prompt is header-pinned so the per-session append-only wire body (KV-cache prefix property) is untouched. Live E2E: with the section, a no-tool question about date + cwd is answered correctly in one line; the section is durable in the session header. Unit tests: prefix preservation, date shape, known-date table. Compose note: rebases cleanly under plan mode's default_prompt_for() as build_default_prompt(plan_mode).
ajianaz
force-pushed
the
feat/context-sections
branch
from
September 22, 2026 10:31
8c94362 to
256df59
Compare
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.
What (description of the change)
Fresh default-path sessions now pin a one-line dynamic context section after the default system prompt:
Context: working directory <cwd>; today is <YYYY-mm-dd> (UTC).(pattern reference: ZCode's context sections, Apache-2.0 — pattern only).build_default_prompt()= incumbentdefault_system_prompt()verbatim + the context line. ONE line maximum by design — no env dumps, no git status, no fingerprints.civil_from_days()extracted fromfmt_mtime()(same Hinnant algorithm, now shared + unit-tested); newtoday_utc().--system/TOLE_SYSTEM_PROMPTstill win untouched (B2 precedence). The assembled prompt is pinned in the session header as today — per-session wire bodies stay append-only, so the KV-cache prefix property is untouched.default_prompt_for(plan_mode)once feat: plan mode — read-only planning constraint (#109) #112 merges (build_default_prompt(plan_mode)).Why (the problem you're solving)
Closes #111. The model answered "what's today's date / where are we working" by burning a tool call (or hallucinating). One static line at session start removes that class of turns at zero runtime cost.
Testing (how you verified this works)
build_default_prompt= incumbent prefix preserved + exactly one appended line; date shape asserted;civil_from_dayspinned against computed known dates (1970-01-01, 2024-01-01, 2026-07-12).--no-default-features) profile green; clippy clean; cora review: No issues found.systemPromptfield verified).