Repository navigation
Add history and notes tools for token-budget sessions - #39827
copyberry[bot] merged 1 commit into
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
## Why Token-budget sessions need a way to recover prior conversation context and preserve working state across context-window transitions. ## What changed - Add direct-model `history` tools for listing windows and items, reading items, and searching conversation contents. - Add direct-model `notes` tools for listing, reading, searching, appending, and writing persistent notes. - Route tool calls through the configured Codex backend with trusted session and agent context, bounded request arguments, and truncation-aware output handling. - Expose the extension when `features.token_budget.use_history_notes_history` is enabled with an OpenAI provider and Codex backend authentication. ## Testing - Cover tool registration, configuration changes, provider and authentication requirements, backend request context, encrypted output preservation, and request and response limits. GitOrigin-RevId: 43b259f01014ba3f30803dd7cd5634942407a9bb
9b9a99d to
cb00edc
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b9a99d2ce
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| None => FunctionCallOutputPayload::from_text(formatted_truncate_text( | ||
| &self.result.to_string(), | ||
| self.truncation_policy, | ||
| )), |
There was a problem hiding this comment.
Cap plaintext tool results at 10K tokens
When tool_output_token_limit or model metadata supplies a policy above 10K tokens, this plaintext branch uses that original policy rather than the 10K-token minimum computed in HistoryNotesToolOutput::new; an unbounded notes.read_file response can therefore add far more than 10K tokens as one function-call output. Store and apply the capped policy here as well.
AGENTS.md reference: AGENTS.md:L97-L99
Useful? React with 👍 / 👎.
| ("max_files", MAX_NOTE_SEARCH_FILES), | ||
| ("max_matches_per_file", MAX_NOTE_MATCHES_PER_FILE), | ||
| ], | ||
| Self::NotesReadFile | Self::NotesAppendToFile | Self::NotesWriteFile => &[], |
There was a problem hiding this comment.
Bound note text arguments before retaining them in context
When the model emits a large notes.append_to_file or notes.write_file call, this branch applies no limit to text, and the schema likewise has no maxLength; the advertised 1,000,000-byte file allowance therefore permits a single assistant tool-call item far beyond the context's 10K-token hard cap to be retained for later requests. Enforce a bounded/chunked argument representation before the call enters conversation history.
AGENTS.md reference: AGENTS.md:L97-L99
Useful? React with 👍 / 👎.
| "ext/goal", | ||
| "ext/git-attribution", | ||
| "ext/guardian-v2", | ||
| "ext/history-notes", |
There was a problem hiding this comment.
Refresh the Bazel lockfile for the new Cargo crate
Adding this workspace member and the corresponding Cargo dependency changes the Cargo inputs consumed by the Bazel crate extension, but this commit does not update MODULE.bazel.lock. The CI lock-drift check will reject the change until just bazel-lock-update is run and the resulting lockfile is committed.
AGENTS.md reference: AGENTS.md:L37-L39
Useful? React with 👍 / 👎.
| } | ||
| } | ||
|
|
||
| async fn handle_call(&self, call: ToolCall) -> Result<Box<dyn ToolOutput>, FunctionCallError> { |
There was a problem hiding this comment.
Add end-to-end coverage for model-issued tool calls
The existing app-server test only verifies registration, while the crate integration test invokes the executor directly, so no test_codex integration exercises model dispatch through this handler, backend invocation, and reinjection of the resulting function-call output into the next inference request. Add an SSE-sequence integration covering that complete agent path.
AGENTS.md reference: AGENTS.md:L114-L118
Useful? React with 👍 / 👎.
| NotesListFilesByPrefix, | ||
| NotesReadFile, | ||
| NotesSearchContents, | ||
| NotesAppendToFile, | ||
| NotesWriteFile, |
There was a problem hiding this comment.
Split the rollout into reviewable stages
This non-mechanical change adds 1,232 lines across 21 files and combines config/defaulting, authenticated transport, extension lifecycle, nine tool schemas/executors, and multiple test layers, exceeding both repository size targets. A coherent sequence is to land the config/schema/default-preservation plumbing first, then the shared backend and four history actions with tests, and finally these five notes actions plus their app-server coverage.
AGENTS.md reference: AGENTS.md:L125-L131
Useful? React with 👍 / 👎.
| let response = ReqwestTransport::from_http_client(create_client()) | ||
| .execute(request) |
There was a problem hiding this comment.
Route backend calls through the configured HTTP factory
When respect_system_proxy is enabled and the Codex backend is reachable only through the configured system or PAC proxy, constructing the legacy default client here bypasses the route-aware HttpClientFactory, even though normal model traffic honors that policy. The history and notes tools will consequently fail all backend requests in those environments; pass the configured factory into the extension and build the client for the request route.
Useful? React with 👍 / 👎.
| .is_some_and(|token_budget| token_budget.use_history_notes_history) | ||
| && config.model_provider.is_openai() | ||
| && self.auth_manager.current_auth_uses_codex_backend() |
There was a problem hiding this comment.
Re-evaluate auth eligibility after account changes
When an app-server account logs in, logs out, or switches between API-key and ChatGPT auth while a thread remains open, this eligibility check is not rerun because it is cached only on thread start or a config change. A thread created before login therefore never gains the tools, while one that logs out keeps advertising tools whose backend authentication now fails; track the auth generation or evaluate current auth when contributing tools.
Useful? React with 👍 / 👎.
| let agent_name = input | ||
| .session_source | ||
| .get_agent_path() | ||
| .unwrap_or_else(AgentPath::root) | ||
| .to_string(); |
There was a problem hiding this comment.
Do not map pathless subagents to root history
When a token-budget thread launches the built-in review delegate, its SessionSource::SubAgent(SubAgentSource::Review) has no agent path, so this fallback assigns it /root while the delegate shares the parent's session ID and extensions. Any history lookup or note write by that delegate is consequently performed against the root agent's private state, allowing review work to read or overwrite root notes; either suppress these tools for pathless subagents or derive a distinct stable identity.
Useful? React with 👍 / 👎.
cb00edc to
2110e63
Compare
## Why Token-budget sessions need a way to recover prior conversation context and preserve working state across context-window transitions. ## What changed - Add direct-model `history` tools for listing windows and items, reading items, and searching conversation contents. - Add direct-model `notes` tools for listing, reading, searching, appending, and writing persistent notes. - Route tool calls through the configured Codex backend with trusted session and agent context, bounded request arguments, and truncation-aware output handling. - Expose the extension when `features.token_budget.use_history_notes_history` is enabled with an OpenAI provider and Codex backend authentication. ## Testing - Cover tool registration, configuration changes, provider and authentication requirements, backend request context, encrypted output preservation, and request and response limits. GitOrigin-RevId: 43b259f01014ba3f30803dd7cd5634942407a9bb
2110e63 to
e51ee34
Compare
## Why Token-budget sessions need a way to recover prior conversation context and preserve working state across context-window transitions. ## What changed - Add direct-model `history` tools for listing windows and items, reading items, and searching conversation contents. - Add direct-model `notes` tools for listing, reading, searching, appending, and writing persistent notes. - Route tool calls through the configured Codex backend with trusted session and agent context, bounded request arguments, and truncation-aware output handling. - Expose the extension when `features.token_budget.use_history_notes_history` is enabled with an OpenAI provider and Codex backend authentication. ## Testing - Cover tool registration, configuration changes, provider and authentication requirements, backend request context, encrypted output preservation, and request and response limits. GitOrigin-RevId: 43b259f01014ba3f30803dd7cd5634942407a9bb
e10dd13 to
daa4807
Compare
Add history and notes tools for token-budget sessions
Why
Token-budget sessions need a way to recover prior conversation context and preserve working state across context-window transitions.
What changed
historytools for listing windows and items, reading items, and searching conversation contents.notestools for listing, reading, searching, appending, and writing persistent notes.features.token_budget.use_history_notes_historyis enabled with an OpenAI provider and Codex backend authentication.Testing