Skip to content

fix(core): send the budget-final notice as a message, not a system suffix - #460

Merged
lg2m merged 1 commit into
fix/prompt-cache-rootfrom
fix/prompt-cache-budget-notice
Oct 25, 2026
Merged

lg2m merged 1 commit into
fix/prompt-cache-rootfrom
fix/prompt-cache-budget-notice

Conversation

@lg2m

@lg2m lg2m commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #459.

When a run's turn, tool-call or cost budget runs out, QQ grants one final response turn. It asked for that response by appending the notice to the system prompt. That changed the head of the provider's cached prefix, so the final turn re-sent the whole system prompt and the full history uncached. It is the last turn of a run, when the context is largest. ADR-0054 § 2 already put the checkpoint and continuation notices in messages for this reason; this applies the same rule to the budget-final notice.

The notice is now a framed [QQ runtime notice; not a user instruction] user message, placed last. It is stored with the turn's ordered notices (model_turns.goal_notice, as the goal handoff notices already are), so a later run in the session replays it where the model saw it. No schema or protocol change is needed. The system prompt, its hash, and the turn's static prefix stay the run's own. The now-unused sha2 import in lib.rs is moved to test-only code.

Verification

  • sessions::tests::budgets::turn_budget_grants_one_final_response_then_settles_as_budget_exhausted now asserts that the final request's system prompt equals the first request's, that the notice is the last message, and that a follow-up run replays the notice before "final status". It failed on fix(core): keep the system prompt identical across task workspaces #459's code and passes now.
  • Existing tests that asserted the notice was in the system prompt (a_budget_final_turn_after_a_report_gets_no_continuation_notice, the_budget_final_turn_outranks_a_due_report) now assert the message placement instead.
  • cargo xtask check passes. Two entries in xtask/src/legacy-sleeps.txt moved by one line because the import moved; no new sleeps.
  • docs/design/architecture.md and the PreparedStaticPrefix doc comment no longer say the budget-final turn changes the system text.

@lg2m

lg2m commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T20:41:43.472682Z f5fb6b6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lg2m

lg2m commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: b19255850b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lg2m
lg2m added this pull request to stack #462 October 24, 2026 13:10
@lg2m
lg2m force-pushed the fix/prompt-cache-budget-notice branch from b192558 to f5fb6b6 Compare October 24, 2026 20:26
@lg2m

lg2m commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: f5fb6b6d87

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lg2m
lg2m merged commit 1f4547b into main Oct 25, 2026
7 checks passed
@lg2m
lg2m deleted the fix/prompt-cache-budget-notice branch October 25, 2026 00:11
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.

1 participant