Skip to content

core: allow restricting subagent environments#31662

Draft
frantic-openai wants to merge 1 commit into
mainfrom
codex/subagent-environment-ids
Draft

core: allow restricting subagent environments#31662
frantic-openai wants to merge 1 commit into
mainfrom
codex/subagent-environment-ids

Conversation

@frantic-openai

Copy link
Copy Markdown

Summary

  • Add optional environment_ids to v1 and v2 spawn_agent.
  • Validate explicit child selections against ready parent-turn environments, preserve parent order, and support an empty selection.
  • Filter fork-inherited selected capability roots to the same environment subset.
  • Add schema, selection, capability-root, and remote/local integration coverage.

Why

A root thread with both local and remote environments currently passes every selected environment to each child. That means a child intended to work only on Windows can still explicitly target local.

This MVP lets the parent spawn a child with, for example, environment_ids: ["windows"]. While that child is loaded, tool calls naming an omitted environment are rejected.

Known limitation

This is a spawn-time, loaded-session restriction. Environment selections are not yet persisted for cold resume; a V2 residency reload or later cold resume reconstructs the thread from default environment selections, so include_local may reattach local. Persisting the subset across resume is a follow-up.

Validation

  • just test -p codex-core spawn_agent_environment_ids (5 passed)
  • just test -p codex-core spawn_agent_tool_v (2 passed)
  • just test -p codex-core --lib spawn_agent_restricted_fork_filters_selected_capability_roots (1 passed)
  • just test -p codex-core --test all spawned_agent_can_restrict_inherited_environments (1 passed locally; body is guarded when no remote fixture is available)
  • just fix -p codex-core
  • just fmt
  • git diff --check

I also ran the full just test -p codex-core suite earlier: 2813 passed, 137 failed, and 18 skipped. The failures were unrelated local-host fixture failures such as missing codex-code-mode-host / test_stdio_server and sandbox/PTY environment failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant