mirror of
https://github.com/openai/codex.git
synced 2026-10-24 18:18:41 +00:00
Support standalone tool outputs in turn/start (#41002)
## What changed - Add an optional `toolOutput` to `turn/start` for starting or steering a turn with a named function-call output instead of user input. - Emit standalone outputs as `functionCallOutput` thread items, persist them in durable history, and include them in resumed threads. - Validate that tool outputs have a name, are not combined with nonempty `input`, satisfy the text-size limit, and use supported image URLs. ## Testing - Cover standalone tool-output notifications, model input, and resumed history in both legacy and paginated history modes. - Cover the text-size limit for structured tool output. GitOrigin-RevId: a1eeec7b9b7de67b1a1c5e829a54552b85ec118b
This commit is contained in:
@@ -25,6 +25,7 @@ use codex_hooks::hook_execution_mode_label;
|
||||
use codex_hooks::hook_handler_type_label;
|
||||
use codex_otel::HOOK_RUN_DURATION_METRIC;
|
||||
use codex_otel::HOOK_RUN_METRIC;
|
||||
use codex_protocol::items::FunctionCallOutputItem;
|
||||
use codex_protocol::items::TurnItem;
|
||||
use codex_protocol::items::UserMessageItem;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
@@ -659,6 +660,24 @@ pub(crate) async fn record_pending_input(
|
||||
TurnInput::FunctionCallOutput(item) => {
|
||||
sess.record_conversation_items(turn_context, std::slice::from_ref(&item))
|
||||
.await;
|
||||
if let ResponseItem::FunctionCallOutput {
|
||||
id: Some(id),
|
||||
name: Some(name),
|
||||
namespace,
|
||||
output,
|
||||
..
|
||||
} = item
|
||||
{
|
||||
let item = TurnItem::FunctionCallOutput(FunctionCallOutputItem {
|
||||
id: id.to_string(),
|
||||
name,
|
||||
namespace,
|
||||
output: output.body,
|
||||
});
|
||||
sess.emit_turn_item_started(turn_context, &item).await;
|
||||
sess.emit_turn_item_completed(turn_context, item).await;
|
||||
}
|
||||
sess.ensure_rollout_materialized(persist_context).await;
|
||||
}
|
||||
TurnInput::InterAgentCommunication(communication) => {
|
||||
sess.record_inter_agent_communication(turn_context, communication)
|
||||
|
||||
Reference in New Issue
Block a user