--exec: a sub-agent that reaches max_iterations ends the whole run instead of handing back to its parent
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start with pkg/runtime/agent_delegation.go to trace how child sessions inherit iteration and non-interactive settings, then read enforceMaxIterations in pkg/runtime/loop_steps.go and the --exec handling in pkg/cli/runner.go. Reproduce with the supplied team configuration and non-terminal stdin; confirm that a helper capped at one iteration returns control to the root, which then completes its run.
Written by the indexing model from the issue text.
Description
Description
In docker agent run --exec, a sub-agent that reaches its max_iterations ends the whole run. Its lead never gets control back, so the lead cannot finish, summarise or report what the sub-agent did. The run exits 0.
Versions: v1.152.0 and v1.161.0, Linux, stdin not a terminal (CI or an unattended job).
Steps to reproduce
The provider is an OpenAI-compatible stub that answers with tool calls.
agents:
root:
model: m
instruction: lead
max_iterations: 20
sub_agents: [helper]
helper:
model: m
instruction: helper
max_iterations: 1
toolsets:
- type: todo
- The root's first answer is
transfer_tasktohelper. - The helper answers with several
create_todoscalls, then text. - Run
docker agent run team.yaml --exec go </dev/null.
Result: one helper call, then
⚠️ Maximum iterations (1) reached. The agent may be stuck in a loop.
Do you want to continue for 10 more iterations? (y/n):
Failed to read input, exiting...
and exit 0. The root's next model call never happens.
With the helper at max_iterations: 0 (no cap), the helper finishes and the root gets transfer_task response → "…" as expected.
Why (from the source, v1.161.0)
- Each
transfer_taskstarts a child session with the sub-agent's own cap (pkg/runtime/agent_delegation.go,session.WithMaxIterations(childAgent.MaxIterations())). - In
enforceMaxIterations(pkg/runtime/loop_steps.go), aNonInteractivesession stops itself and appends "Execution stopped after reaching the configured max_iterations limit". For a sub-agent, that would return its turn to the lead. - The
--execCLI path never marks the sessionNonInteractive, andtransfer_taskcopies the parent's value. So theMaxIterationsReachedEventreaches the CLI runner (pkg/cli/runner.go). The runner prompts, the read fails without a terminal, and it callsrt.Resume(ResumeReject(""))andreturn nil, which ends the whole run.
Expected
In --exec with no terminal, a capped sub-agent stops and hands its turn back to its parent, as a NonInteractive session already does, instead of the CLI ending the run. Possible approaches:
- mark
--execsessionsNonInteractivewhen stdin is not a terminal; - or have the CLI, on a failed read, reject only the session that reached its cap.
--yolo avoids the prompt, but it also auto-approves every tool call, which an unattended run with a restricted permission set cannot accept.
Related: #4560 (the continuation increment).
- Dominant language
- Go
- Stars
- 4.7k
- Forks
- 565
- Avg merge
- 18h 52m
- Merged PRs (30d)
- 221
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from docker/docker-agent
-
edit_file diff rendering panics on invalid UTF-8 textPossibly taken @TDnorthgarden claimed this today. Openarea/tui
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
docker/docker-agent#4955 ·
Maintainers usually reply within 1 day
-
A setting to turn off the models.dev catalog download (offline and strict-network use)Possibly taken @3431481073 claimed this 19 days ago. Openarea/config area/models
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
docker/docker-agent#4714 ·
Maintainers usually reply within 1 day
-
Error when trying to run sandbox example?Possibly taken @dgageot claimed this 27 days ago. Openarea/cli
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
docker/docker-agent#4672 · 1 comment · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
-
`edit_file` silently edits the first match when `oldText` occurs more than oncePossibly taken @dwin-gharibi claimed this 103 days ago. Openarea/tools
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
docker/docker-agent#3929 · 2 comments ·
Maintainers usually reply within 1 day
-
area/api area/runtime
Difficulty 4/5 3-5 days Newbie friendliness 48/100
docker/docker-agent#4951 ·
Maintainers usually reply within 1 day
All issues in docker/docker-agent
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OneBusAway/maglev#2145 ·
Maintainers usually reply within 2 days
-
priority/medium status/ready type/chore
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
discobox-ai/discobox#1357 ·
Maintainers usually reply within 1 day
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for itPossibly taken @fzn0x claimed this today. Openbug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
enhancement ui/ux
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jbigler/railswitch#243 ·
Maintainers usually reply within 1 day
-
Helm probes fail when DCGM Exporter requires TLS client certificatesPossibly taken @git-jxj claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NVIDIA/dcgm-exporter#775 ·
Maintainers usually reply within 1 day