mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
## What changed Represent host-verified tool metadata as `TrustedTool` in `codex-guardian-context` and collect it through an async-only context section. Route Guardian v2 sampling through that section while preserving separate developer-message delivery and the 512-token rendering budget. Omit tool metadata from debug output. ## Testing Move the rendering-budget test into the shared crate, extend registry coverage for async-only collection and debug redaction, and narrow the scoped approval test to messages tagged `guardian.trusted_tool`. GitOrigin-RevId: ee7cb4e9b9ceced70438cb58060d1a2973e1dc6a
21 lines
699 B
Rust
21 lines
699 B
Rust
use super::MAX_TRUSTED_TOOL_CONTEXT_TOKENS;
|
|
use super::TRUSTED_TOOL_PREFIX;
|
|
use super::TrustedTool;
|
|
use codex_context_fragments::ContextualUserFragment;
|
|
use codex_protocol::protocol::TruncationPolicy;
|
|
|
|
#[test]
|
|
fn trusted_tool_context_has_a_hard_token_budget() {
|
|
let fragment = TrustedTool {
|
|
server: "server".into(),
|
|
connector_id: None,
|
|
source: "unbounded instructions ".repeat(1_000),
|
|
};
|
|
let context = fragment.render();
|
|
assert!(context.starts_with(TRUSTED_TOOL_PREFIX));
|
|
assert!(
|
|
context.len() <= TruncationPolicy::Tokens(MAX_TRUSTED_TOOL_CONTEXT_TOKENS).byte_budget()
|
|
);
|
|
assert!(context.contains("<truncated omitted_approx_tokens="));
|
|
}
|