Allow per-turn overrides for direct-only tool namespaces (#59481)

## What changed

- Add `direct_only_tool_namespaces` to `TurnStartOptions`. Omission inherits the thread configuration; an empty list clears direct-only routing for that turn. Steering ignores the option.
- Persist explicit overrides in turn context and restore them when recovering an interrupted turn, including turns started by standalone tool output.
- Keep subsequent turns and spawned or resumed child agents on the thread's routing defaults.

## Testing

Add coverage for routing changes across turns in Responses and Responses Lite, recovery without carrying overrides into subsequent turns, and child-agent inheritance.

GitOrigin-RevId: cea1a997424572d4cd372cd15b098626904c6796
This commit is contained in:
Henry Levy
2026-11-04 19:58:49 +00:00
committed by copyberry
parent 41cbd5b9b2
commit d78f68f8d1
24 changed files with 322 additions and 39 deletions
+5
View File
@@ -3634,6 +3634,10 @@ pub struct TurnContextItem {
/// Root turn that owns this turn's attribution, retained across recovery.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub root_turn_id: Option<String>,
/// Explicit routing for this turn. An empty list clears the thread's direct namespaces.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub direct_only_tool_namespaces: Option<Vec<String>>,
/// Plugin selection captured for this turn. Absent in older histories.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
@@ -6594,6 +6598,7 @@ mod tests {
let item = TurnContextItem {
turn_id: None,
root_turn_id: None,
direct_only_tool_namespaces: None,
disabled_plugin_ids: None,
cwd: test_path_buf("/tmp").abs(),
approval_policy: AskForApproval::Never,
+3
View File
@@ -241,6 +241,9 @@ pub struct TurnStartOptions {
/// Structured-output schema for a new turn. When steering, Core rejects
/// the input if the active turn uses a different schema.
pub final_output_json_schema: Option<Value>,
/// Direct-only tool namespaces for a new turn. Omission inherits the thread's
/// configuration. An empty list clears it for this turn. Ignored when steering.
pub direct_only_tool_namespaces: Option<Vec<String>>,
/// Service tier for a new turn, without changing the thread's preference.
pub service_tier: Option<String>,
/// Lifetime requested for new Responses prompt cache entries during this turn.