mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Preserve client attribution when spawning subagents (#62072)
## Why Delegated work should retain client attribution such as `cost_center` from the turn that requested it, even when a yielded code-mode cell spawns its child after a newer parent turn starts. ## What changed Capture client metadata from the originating turn and apply it to the child's initial turn in both legacy and v2 agent spawning. Children and grandchildren retain the captured values when the parent is later steered with updated metadata. Exclude `misalignment_override`, `parent_response_id`, and `mcp_request_meta` from inheritance, while preserving each child's own thread and turn identifiers. ## Testing Add coverage for metadata filtering and snapshot isolation, legacy and v2 spawning with fresh or forked history, grandchild inheritance, and spawning from a yielded code-mode cell after the parent advances to another turn. GitOrigin-RevId: 8c378c49239ccfac03deb2b793fc69aba1d41644
This commit is contained in:
@@ -994,6 +994,7 @@ impl LocalAgentControl {
|
||||
turn_trigger: options.turn_trigger,
|
||||
root_turn_id: options.root_turn_id,
|
||||
cyber_access_program,
|
||||
inherited_client_metadata: options.inherited_client_metadata,
|
||||
..Default::default()
|
||||
};
|
||||
let input_admission_started_at = Instant::now();
|
||||
|
||||
@@ -7,6 +7,7 @@ use codex_protocol::AgentPath;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::protocol::AgentStatus;
|
||||
use codex_protocol::turn_input::CyberAccessProgram;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Registry identity shared by loaded and unloaded agents.
|
||||
/// Registered agents have an `agent_id`; a reserved spawn can still be awaiting its ID.
|
||||
@@ -41,6 +42,8 @@ pub struct SpawnAgentOptions {
|
||||
/// Attribute delegated usage to the turn that initiated it.
|
||||
pub turn_trigger: Option<String>,
|
||||
pub root_turn_id: Option<String>,
|
||||
/// Client attribution captured from the turn that requested the child.
|
||||
pub inherited_client_metadata: HashMap<String, String>,
|
||||
/// Inheritable bindings captured by the step that requested the child.
|
||||
pub environments: Option<TurnEnvironmentSnapshot>,
|
||||
/// Plugin choices from the turn requesting the child. Omission inherits the parent's
|
||||
|
||||
Reference in New Issue
Block a user