Skip to content

[v0.8 Prompts P01] preserve typed system-prompt provenance - #1177

Open
sethkarten wants to merge 23 commits into
mainfrom
v080/prompts
Open

[v0.8 Prompts P01] preserve typed system-prompt provenance#1177
sethkarten wants to merge 23 commits into
mainfrom
v080/prompts

Conversation

@sethkarten

@sethkarten sethkarten commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve typed system-prompt provenance through resource loading and session rebuilds.
  • Treat an explicitly empty caller prompt as custom instead of falling back to the built-in prompt.
  • Fail closed when prompt provenance is unknown.
  • Keep the new ResourceLoader method optional for existing SDK loaders and export SystemPromptSource from the package root.

Cleanup

  • Merged the current main branch without rewriting published history.
  • Removed unrelated control-loop and clear-prose prompt policy changes.
  • Removed the test-only provenance override, unused diagnostics, duplicate validation, and overlapping copy-based tests.
  • Retained behavioral coverage for loader distinction, root replacement, child creation/reload, and unknown provenance.

Validation

  • npm run check
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/agent-session-runtime-events.test.ts test/suite/agent-session-runtime.test.ts test/system-prompt.test.ts — 55 passed
  • npx tsx ../../node_modules/vitest/dist/cli.js --run test/resource-loader.test.ts -t "distinguishes an absent system prompt" — 1 passed
  • Independent review approved the final diff.

Note

Preserve caller-provided empty system prompt provenance across session rebuilds

  • Introduces SystemPromptSource discriminated union (built_in | custom | unknown) in system-prompt.ts to track whether a system prompt came from the built-in default or was explicitly provided by the caller
  • buildSystemPrompt now uses resolveSystemPromptSource to reconcile the new systemPromptSource option with the legacy customPrompt field; an empty-string custom prompt is treated as custom rather than falling back to the built-in prompt, and unknown provenance fails closed by returning an empty string
  • DefaultResourceLoader.extendResources distinguishes absent (undefined) from present-empty ("") system prompt config and exposes the resolved source via the new getSystemPromptSource() getter
  • AgentSession passes systemPromptSource into _baseSystemPromptOptions instead of customPrompt, preserving empty custom prompts across newSession() rebuilds
  • Risk: buildSystemPrompt returns an empty string for unknown provenance instead of assembling a default prompt; callers that previously relied on fallback behavior for malformed or missing provenance data will get an empty system prompt

Macroscope summarized 2584ae8.


Note

Medium Risk
Changes how agent system prompts are chosen, including fail-closed behavior for unknown provenance. Incorrect provenance can alter model instructions across session rebuilds.

Overview
Fixes empty caller-provided system prompts being treated as absent and replaced by the built-in agent prompt on session rebuilds.

Introduces typed SystemPromptSource (built_in | custom | unknown). buildSystemPrompt now uses that provenance: empty custom content is kept, and unknown provenance returns "" instead of assembling the default prompt.

DefaultResourceLoader distinguishes unset vs explicitly empty systemPrompt, and sessions prefer getSystemPromptSource() (optional on existing loaders) when rebuilding prompts.

Reviewed by Cursor Bugbot for commit 2584ae8. Bugbot is set up for automated code reviews on this repo. Configure here.

samsja and others added 8 commits August 10, 2026 14:33
Add an IPYTHON_CONTROL_PROMPT line instructing the agent to never block the
kernel with time.sleep() loops or long sleeps to await slow external work
(background runs, sandboxes, sub-agents, remote jobs). A blocked cell holds
the turn open, wastes wall-clock, and prevents user interaction. The agent
should kick off the work, record its handle/output location, end the turn,
and check results on a later turn.

Update system-prompt.test.ts exact-match block and add a toContain assertion.
@sethkarten

Copy link
Copy Markdown
Contributor Author

v0.8 stack checkpoint — 2026-08-11 15:50 UTC

This draft PR remains the GitHub Prompts stack surface and will be kept current.

  • Parent Core candidate: 41ef592f8474a1d67b25ee6e495df24be3ab804e (feat(coding-agent): finalize v0.8 Core lifecycle and project MCP hardening #1224), exact CI green.
  • Latest independently reviewed local prompt candidate: 839e06651165255e4802215c69ff7a5a49e082b0 (nine exact prompt/test paths).
  • Active next step: semantic reconstruction of that reviewed tree onto Core 41ef, full prompt/resource/system tests, typecheck, nonwriting Biome, fresh review, then append-only/non-force advancement of this PR branch.

The current remote tip is historical until that verified successor lands; this is not a readiness claim.

@sethkarten sethkarten changed the title [v0.8 Prompts 1/2] add nonblocking and plain-language defaults [v0.8 Prompts P01] preserve typed system-prompt provenance Aug 11, 2026
@sethkarten
sethkarten changed the base branch from main to v080/final-core-main-project-mcp-hardened August 11, 2026 16:58
@macroscopeapp

macroscopeapp Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Macroscope has since reviewed this pull request. An earlier review was skipped by a cost limit; a review has now completed, so that notice no longer applies.

@sethkarten
sethkarten changed the base branch from v080/final-core-main-project-mcp-hardened to main August 11, 2026 18:11
@sethkarten sethkarten closed this Aug 11, 2026
Comment thread packages/coding-agent/src/core/agent-session.ts
@sethkarten sethkarten reopened this Aug 11, 2026
@sethkarten
sethkarten marked this pull request as ready for review August 11, 2026 18:22
@sethkarten
sethkarten requested review from alexzhang13, skirsten and snimu and removed request for skirsten August 11, 2026 18:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b54903c. Configure here.

getThemes(): { themes: Theme[]; diagnostics: ResourceDiagnostic[] };
getAgentsFiles(): { agentsFiles: Array<{ path: string; content: string }> };
getSystemPrompt(): string | undefined;
getSystemPromptSource?(): SystemPromptSource;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provenance migration scaffolding remains

Low Severity

P01 keeps transitional dual APIs after the provenance migration: optional getSystemPromptSource?() with a string-fallback helper, plus retained customPrompt beside systemPromptSource. That staging surface duplicates resolution logic and leaves compatibility vocabulary in the completed P01 change.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: Review rules

Reviewed by Cursor Bugbot for commit b54903c. Configure here.

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.

3 participants