diff --git a/codex-rs/core/src/tools/code_mode/execute_handler.rs b/codex-rs/core/src/tools/code_mode/execute_handler.rs index 2706ea3219..8c550ab925 100644 --- a/codex-rs/core/src/tools/code_mode/execute_handler.rs +++ b/codex-rs/core/src/tools/code_mode/execute_handler.rs @@ -10,7 +10,7 @@ use codex_tools::ToolSpec; use super::ExecContext; use super::PUBLIC_TOOL_NAME; -use super::code_mode_output_truncation_policy; +use super::code_mode_history_truncation_policy; use super::handle_runtime_response; use super::is_exec_tool_name; @@ -124,12 +124,8 @@ impl CoreToolRuntime for CodeModeExecuteHandler { fn history_truncation_policy( &self, - invocation: &ToolInvocation, + _invocation: &ToolInvocation, ) -> Option { - let ToolPayload::Custom { input } = &invocation.payload else { - return None; - }; - let args = codex_code_mode::parse_exec_source(input).ok()?; - Some(code_mode_output_truncation_policy(args.max_output_tokens)) + Some(code_mode_history_truncation_policy()) } } diff --git a/codex-rs/core/src/tools/code_mode/mod.rs b/codex-rs/core/src/tools/code_mode/mod.rs index 256548a5f6..f5d5c87af0 100644 --- a/codex-rs/core/src/tools/code_mode/mod.rs +++ b/codex-rs/core/src/tools/code_mode/mod.rs @@ -245,6 +245,10 @@ pub(super) fn code_mode_output_truncation_policy( TruncationPolicy::Tokens(resolve_max_tokens(max_output_tokens)) } +pub(super) fn code_mode_history_truncation_policy() -> TruncationPolicy { + TruncationPolicy::Bytes(usize::MAX) +} + async fn call_nested_tool( _exec: ExecContext, tool_runtime: ToolCallRuntime, diff --git a/codex-rs/core/src/tools/code_mode/wait_handler.rs b/codex-rs/core/src/tools/code_mode/wait_handler.rs index 863372b64b..f9327c42e2 100644 --- a/codex-rs/core/src/tools/code_mode/wait_handler.rs +++ b/codex-rs/core/src/tools/code_mode/wait_handler.rs @@ -15,7 +15,7 @@ use codex_tools::ToolSpec; use super::DEFAULT_WAIT_YIELD_TIME_MS; use super::ExecContext; use super::WAIT_TOOL_NAME; -use super::code_mode_output_truncation_policy; +use super::code_mode_history_truncation_policy; use super::handle_runtime_response; use super::wait_spec::create_wait_tool; @@ -117,13 +117,9 @@ impl ToolExecutor for CodeModeWaitHandler { impl CoreToolRuntime for CodeModeWaitHandler { fn history_truncation_policy( &self, - invocation: &ToolInvocation, + _invocation: &ToolInvocation, ) -> Option { - let ToolPayload::Function { arguments } = &invocation.payload else { - return None; - }; - let args: ExecWaitArgs = parse_arguments(arguments).ok()?; - Some(code_mode_output_truncation_policy(args.max_tokens)) + Some(code_mode_history_truncation_policy()) } fn pre_tool_use_payload(&self, _invocation: &ToolInvocation) -> Option {