Skip to content

subagent-limit-guard still unconditionally rewrites [features.multi_agent_v2] max_concurrent_threads_per_session = 1000 (v4.17.0) — v2 follow-up to #97 #130

Description

@catallactics

Summary

ensureSubagentConcurrencyLimit() ends by calling ensureMultiAgentV2ThreadLimit(result) unconditionally, and that helper writes [features.multi_agent_v2] max_concurrent_threads_per_session = 1000 into the user's config.toml on every run — creating the section if absent, and overwriting any user-set value if present. This happens regardless of the selected model, and there is no equivalent of the "hand-removed key stays removed" behavior that the same file deliberately implements for the legacy agents.max_threads path.

Pinned source at v4.17.0 (f39306f):

Why it matters

On multi_agent_v2 sessions (e.g. gpt-5.6-sol), max_concurrent_threads_per_session is effectively the only concurrency gate that holds:

We audited a runaway session on codex-cli 0.144.1 + gpt-5.6-sol where the injected runtime hint "There are 1000 available concurrency slots" appeared 23× in the rollout, alongside a spawn tree of 1,004 descendant threads (depth 11) and ~46 GB RSS before manual intervention. After we restored Codex's stock default (cap 4) by deleting the override, source inspection showed this migration would silently re-write 1000 on the next session start with the plugin enabled — i.e. a user who fixes their config gets re-broken.

What v4.17.0 already improved (appreciated)

The v2 cap write is the remaining piece of #97.

Suggested fix

Any of, in order of preference:

  1. Stop writing max_concurrent_threads_per_session unless the user opts in
  2. Honor existing / hand-removed user values, mirroring the raiseExistingAgentsMaxThreads philosophy already applied to the v1 key
  3. At minimum, make the limit configurable instead of hard-coding "1000"

LAZYCODEX_CONFIG_MIGRATION_DISABLED=1 exists but is all-or-nothing — enabling it also loses the genuinely useful guards (e.g. the #118 cleanup).

Environment

  • codex-cli 0.144.1, model gpt-5.6-sol (multi_agent_v2), macOS
  • Originally observed with OMO 4.15.1; behavior confirmed by source inspection at v4.17.0 (f39306f)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions