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

## 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
This commit is contained in:
pmccrary-oai
2026-08-21 01:02:00 +00:00
committed by copyberry
parent f20b63e85c
commit daa48072f4
21 changed files with 1232 additions and 6 deletions

View File

@@ -289,6 +289,9 @@ impl FeatureConfig for MultiAgentV2ConfigToml {
pub struct TokenBudgetConfigToml {
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
/// Whether to expose the built-in history and notes extension.
#[serde(skip_serializing_if = "Option::is_none")]
pub use_history_notes_history: Option<bool>,
/// Number of tokens remaining before auto-compaction when the wrap-up reminder is emitted.
#[serde(skip_serializing_if = "Option::is_none")]
#[schemars(range(min = 1))]