Skip to content

feat: dynamic context sections in the default system prompt - #114

Merged
ajianaz merged 2 commits into
developfrom
feat/context-sections
Sep 22, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/context-sections

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

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() = incumbent default_system_prompt() verbatim + the context line. ONE line maximum by design — no env dumps, no git status, no fingerprints.
  • civil_from_days() extracted from fmt_mtime() (same Hinnant algorithm, now shared + unit-tested); new today_utc().
  • Applied ONLY on the default path: explicit --system / TOLE_SYSTEM_PROMPT still 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.
  • Compose note: rebases cleanly under plan mode's 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)

  • Unit: build_default_prompt = incumbent prefix preserved + exactly one appended line; date shape asserted; civil_from_days pinned against computed known dates (1970-01-01, 2024-01-01, 2026-07-12).
  • Full suites green; mobile (--no-default-features) profile green; clippy clean; cora review: No issues found.
  • Live E2E (glm-5.1, release binary): asked to answer date + cwd WITHOUT any tool call → "Today is 2026-09-22 (UTC) and the working directory is /tmp/ctxt/ws." — correct, zero tool calls; the Context line is durable in the session header (systemPrompt field verified).

@github-actions

Copy link
Copy Markdown

🔍 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
ajianaz force-pushed the feat/context-sections branch from 8c94362 to 256df59 Compare September 22, 2026 10:31
@ajianaz
ajianaz merged commit 107e224 into develop Sep 22, 2026
16 checks passed
@ajianaz
ajianaz deleted the feat/context-sections branch September 22, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: dynamic context sections in the default system prompt

1 participant