Skip to content

Add history and notes tools for token-budget sessions - #39827

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/43b259f01014ba3f30803dd7cd5634942407a9bb
Aug 21, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/43b259f01014ba3f30803dd7cd5634942407a9bb

Conversation

@copyberry

@copyberry copyberry Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

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

  • 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.

@github-actions

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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.

copyberry Bot pushed a commit that referenced this pull request Aug 21, 2026
## 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
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/43b259f01014ba3f30803dd7cd5634942407a9bb branch from 9b9a99d to cb00edc Compare August 21, 2026 01:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +431 to +434
None => FunctionCallOutputPayload::from_text(formatted_truncate_text(
&self.result.to_string(),
self.truncation_policy,
)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P0 Badge 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 => &[],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P0 Badge 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 👍 / 👎.

Comment thread codex-rs/Cargo.toml
"ext/goal",
"ext/git-attribution",
"ext/guardian-v2",
"ext/history-notes",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge 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> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +47 to +51
NotesListFilesByPrefix,
NotesReadFile,
NotesSearchContents,
NotesAppendToFile,
NotesWriteFile,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +59 to +60
let response = ReqwestTransport::from_http_client(create_client())
.execute(request)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +38 to +40
.is_some_and(|token_budget| token_budget.use_history_notes_history)
&& config.model_provider.is_openai()
&& self.auth_manager.current_auth_uses_codex_backend()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +60 to +64
let agent_name = input
.session_source
.get_agent_path()
.unwrap_or_else(AgentPath::root)
.to_string();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/43b259f01014ba3f30803dd7cd5634942407a9bb branch from cb00edc to 2110e63 Compare August 21, 2026 01:21
copyberry Bot pushed a commit that referenced this pull request Aug 21, 2026
## 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
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/43b259f01014ba3f30803dd7cd5634942407a9bb branch from 2110e63 to e51ee34 Compare August 21, 2026 01:21
## 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
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/43b259f01014ba3f30803dd7cd5634942407a9bb branch 2 times, most recently from e10dd13 to daa4807 Compare August 21, 2026 01:25
@copyberry
copyberry Bot merged commit daa4807 into main Aug 21, 2026
37 of 43 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/43b259f01014ba3f30803dd7cd5634942407a9bb branch August 21, 2026 01:26
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 21, 2026

This branch was previously deployed

1 inactive deployment
issue-triage — daa48072 Deployed Aug 21, 2026 by Checkmate95 via Generate label suggestions #38992
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants