Skip to content

fix(runtime): scope harness prompt-selection to fresh vs resume session - #4012

Merged
aheritier merged 1 commit into
mainfrom
fix/harness-delegation-empty-prompt
Aug 21, 2026
Merged

aheritier merged 1 commit into
mainfrom
fix/harness-delegation-empty-prompt

Conversation

@aheritier

Copy link
Copy Markdown
Collaborator

🤖 Automated implementer agent — this comment was posted by the implementer bot from Docker Agentic Platform, not by a human developer

Fixes #4011.

PR #3989 changed harnessInputMessages to return only the latest non-implicit user turn for all sessions. This is correct for resume turns, but breaks transfer_task delegations where the task lives in the system message and the only user message is the implicit "Please proceed." filler — yielding an empty prompt and the error cannot run external harness without a user prompt.

Fix: gate prompt-building on whether a harness session already exists:

  • Fresh (harnessSessionID == ""): freshHarnessMessages collects all system and user messages including implicit ones, so the task/system content reaches the harness. A bare implicit filler with no system/task still returns nil, keeping the empty-prompt guard for that degenerate case.
  • Resume (harnessSessionID != ""): latestUserTurn sends only the latest non-implicit user turn. Preserves feat(runtime): resume external harness sessions #3989's intent.

harnessPrompt is updated to concatenate content from all supplied messages (system + user) so task text from the system message is included in the prompt on fresh sessions.

Testing: all existing harness tests pass; added TestHarnessDelegatedTaskWithImplicitUserMessage as a regression test that mirrors what newSubSession builds for a transfer_task delegation.

Fixes #4011.

PR #3989 (commit 992c8c0) changed harnessInputMessages to return only the
latest non-implicit user message. This is correct for resume turns, where the
harness already holds prior context. But transfer_task builds sub-sessions where
the task lives in the system message and the only user message is the implicit
'Please proceed.' filler (Implicit=true). With the old guard that filler was
filtered out, harnessInputMessages returned nil, prompt was empty, and the run
was rejected with 'cannot run external harness without a user prompt' before the
harness launched.

Fix: gate the prompt-building strategy on whether a harness session already exists:

- Fresh session (harnessSessionID == ""): collect all system and user messages
  (including implicit) from the session snapshot so the task/system content
  reaches the harness. A bare implicit filler with no system/task still returns
  nil, keeping the empty-prompt guard for that genuinely degenerate case.
- Resume (harnessSessionID != ""): keep sending only the latest non-implicit
  user turn. Preserves #3989's intent for multi-turn harness sessions.

harnessPrompt is updated to concatenate content from all supplied messages
(system and user) rather than returning only the last user message, so the task
text from the system message is included in the harness prompt on fresh sessions.

Add TestHarnessDelegatedTaskWithImplicitUserMessage as a regression test.
@aheritier
aheritier marked this pull request as ready for review August 21, 2026 14:56
@aheritier
aheritier requested a review from a team as a code owner August 21, 2026 14:56
@aheritier
aheritier enabled auto-merge August 21, 2026 15:00
@aheritier aheritier added area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Aug 21, 2026
@aheritier
aheritier merged commit 1e42e24 into main Aug 21, 2026
16 checks passed
@aheritier
aheritier deleted the fix/harness-delegation-empty-prompt branch August 21, 2026 15:03
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
docker-agent 1.127.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>This release delivers Desktop PAC-aware egress with SSRF protections, several runtime and toolset fixes, and documentation updates for served-agent safety controls.

## What's New

- Adds Desktop PAC-aware egress for configured HTTP clients while preserving standalone proxy behavior and SSRF protections, covering agent/source fetches, sessions, tools, MCP HTTP transports, and MCP OAuth flows

## Bug Fixes

- Fixes slow toolset startup from blocking conversation turns; keeps turns responsive when a toolset start is already in progress or exceeds the start budget
- Fixes `on_user_input` notifications firing incorrectly for sub-sessions, background agents, non-interactive runs, and canceled max-iteration waits — now only fires when an interactive root session is genuinely waiting for the next prompt
- Fixes Desktop PAC transport detection, routing, and state retention across multiple egress and transport handling regressions
- Fixes server to distinguish unavailable agent sources

## Technical Changes

- Extends Windows streaming TUI test timeouts to 30 seconds for simulated-stream scenarios
- Updates CLI reference documentation for `serve a2a` safety flags (`--auth-token`, `--cors-origin`, `--insecure-no-auth`, `--safety`)
- Adds documentation describing Desktop PAC egress controls and clarifying coverage for MCP OAuth and direct egress
- Makes Desktop transport tests hermetic
---

## What's Changed
* docs: update CHANGELOG.md for v1.126.0 by @docker-read-write[bot] in docker/docker-agent#4002
* docs: complete CLI reference for serve a2a safety flags by @aheritier in docker/docker-agent#4003
* test(e2e): extend Windows streaming TUI timeouts by @Sayt-0 in docker/docker-agent#4005
* fix: add Desktop PAC-aware egress with SSRF protections by @aheritier in docker/docker-agent#3999
* fix(runtime): avoid false on_user_input notifications by @Sayt-0 in docker/docker-agent#4010
* fix(tools): prevent slow startup from blocking turns by @Sayt-0 in docker/docker-agent#4009
* fix(runtime): scope harness prompt-selection to fresh vs resume session by @aheritier in docker/docker-agent#4012


**Full Changelog**: docker/docker-agent@v1.126.0...v1.127.0
</pre>
  <p>View the full release notes at <a href="https://github.com/docker/docker-agent/releases/tag/v1.127.0">https://github.com/docker/docker-agent/releases/tag/v1.127.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!17388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configured Claude Code harness rejected before launch despite prior confirmation

2 participants