Repository navigation
fix(agent): preserve prompt cache stability across providers and GPT-6.2 Responses - #7099
Merged
Merged
Conversation
Encode OpenAI Responses system messages as leading developer input messages, stop duplicating the system prompt into top-level instructions on ChatGPT Codex subscriptions, deduplicate repeated skill catalog sections in driver_model::append_skill, and add GPT-6.1/6.2 models to catalog-facts.json. Generated-by: Google Antigravity
… loaded tool order Share prior-run skill catalog inheritance between driver_model and driver_executor so Goal, ScheduledTask, SessionCompletion, and compaction runs do not drop the skills catalog and bust prompt caches. Preserve activation order for dynamically discovered tools and append them after the static direct + tool_search prefix. Generated-by: Google Antigravity
…d map chatgpt catalog Anchor inherited skill resolution inside inherited_messages so continuation admission and first dispatch compute identical system prompts; read prior RunSource.spec.input directly without view_at folding or a 16-run cap; map live chatgpt Snapshot lookups to openai-codex bundled/public entries; replace trivial helper test with end-to-end continuation and provider tests. Generated-by: Google Antigravity
…p interactive history scan Restore continuation skill inheritance in project_step_input's view.baseline branches so post-compaction tool continuations retain the same system prompt. Short-circuit interactive runs that already passed through prepare_skills (by Trigger::Message + interactive MessageOrigin) to avoid O(N^2) history walks when no skill library is configured. Generated-by: Google Antigravity
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
Aligns Maka's OpenAI Responses / ChatGPT Codex wire format with GPT-6.2 prompt caching rules and fixes three cross-provider prompt cache invalidation bugs:
Cross-provider prompt cache stability
driver_model(plugins/agent/native/src/owner/driver_model.rs,plugins/agent/native/src/owner/driver_executor.rs,plugins/agent/native/src/owner/skills.rs): Background wake-ups (Goal,ScheduledTask,SessionCompletion,CheckpointHandoff,ContextCompact) bypassprepare_skills. Previously onlydriver_executorinherited the most recent prepared run's skill catalog, while nativedriver_modeldropped it — flippingsystem.texttwice (once on wakeup, once on the next user message) and busting 100% of the prompt cache across all providers. Both drivers now shareresolve_input_skills, stopping at any prepared run (even if its catalog is empty) so cleared skills are not resurrected.driver_model::append_skill(plugins/agent/native/src/owner/driver_model.rs): Repeated merges during steering or ancestry replay previously appended duplicate copies of the same available-skills catalog tosystem.text, mutating the leading system message and invalidating prefix caches across all providers.tool_search-loaded tools in activation order (platform/session-state/src/lib.rs,plugins/agent/state/src/cells.rs,plugins/agent/state/src/cells/sql.rs,plugins/agent/tool-catalog/src/availability.rs,plugins/agent/native/src/owner/driver.rs): Persist loaded tool names in activation order instead of alphabeticalBTreeSetorder, and emit wire tool definitions as[direct tools..., tool_search, loaded deferred tools in activation order...]so discovering a tool never shifts the preceding static or previously-loaded tool prefix.OpenAI Responses / ChatGPT Codex (GPT-6.2)
Starting with GPT-6.2 (Astra and Sol), OpenAI's Responses API appends top-level
instructionsafter theinputarray and after all cache breakpoints, billing those tokens at full uncached input rates on every turn. Reusable instructions must live in leadingdevelopermessages insideinput.role: "developer"for OpenAI Responses system messages (plugins/agent/provider-protocol/src/responses/request.rs,plugins/agent/model/src/adapters/wire/responses.rs): EncodeMessage::Systemasrole: "developer"forOpenaiResponseswhile keepingrole: "system"for third-party plaintextOpenResponses.instructionsfor ChatGPT Codex (plugins/agent/model/src/adapters/codex.rs):codex::preparepreviously copiedMessage::Systeminto top-levelinstructionswithout removing it frominput[0], sending the system prompt twice and burning an uncached copy on every turn. Live probes againstchatgpt.com/backend-api/codex/responsesconfirm omitted top-levelinstructionsworks acrossgpt-5.6-sol,gpt-6-sol,gpt-6.1-sol, andgpt-6.2-solover both HTTP SSE and WebSocketprevious_response_idcontinuations. Explicit caller-suppliedinstructionsare still preserved.plugins/agent/providers/data/catalog-facts.json,plugins/agent/providers/tests/integration/api/mod.rs): Addgpt-6.1-sol,gpt-6.1-terra,gpt-6.2-astra, andgpt-6.2-soltoopenaiandopenai-codexmatching verified API and Codex inventory metadata.Verification
gpt-6.2-sol):developermessage multi-turn: T1cache_write_tokens: 6176, T2cached_tokens: 6176 / 6196.instructionsmulti-turn: T1 & T2cache_write_tokens: 0,cached_tokens: 0.reasoning.effortsupport ongpt-6.2-solandgpt-6.2-astra(low..max, rejectingnoneandultra).chatgpt.com/backend-api/codex/responses):instructionswith leadingdevelopermessage returned200 OKongpt-5.6-sol,gpt-6-sol,gpt-6.1-sol, andgpt-6.2-sol.gpt-6.2-solHTTP SSE 2-turn:cached_tokens: 4224 / 4370.gpt-6.2-solWebSocketprevious_response_idcontinuation without top-levelinstructions: preserved turn-1 developer instructions and hitcached_tokens: 2688 / 2875.cargo test -p maka-provider-protocol -p maka-providers -p maka-model— passedcargo test -p maka-session-state -p maka-agent-state -p maka-tool-catalog— passedcargo test -p maka-tools learning_a_nested_tool— passedcargo test -p maka-agent-native --lib driver_model— 9 passedcargo test -p maka-agent-native --lib codex— 11 passedrustfmt --edition 2024 --checkon all modified Rust files — passedcargo clippyon all modified crates — zero warnings in modified linesjust check), UI/workbench suites.AI use
Select exactly one:
Tool(s) and scope: Google Antigravity — audited OpenAI GPT-6.2 and cross-provider prompt caching, ran live API/Codex probes, implemented the fixes, and added unit/integration tests.
Checklist
Does this PR entail a change in behavior?