Skip to content

fix(agents): align tool-free completion relay instructions with tool surface - #198689

Open
ElNeMeR70 wants to merge 2 commits into
openclaw:mainfrom
ElNeMeR70:fix/tool-free-completion-relay-instruction
Open

ElNeMeR70 wants to merge 2 commits into
openclaw:mainfrom
ElNeMeR70:fix/tool-free-completion-relay-instruction

Conversation

@ElNeMeR70

Copy link
Copy Markdown

What Problem This Solves

Fixes #198584

When a subagent completion handoff runs on a degraded path where execution tools are stripped (!completionRetainsRequesterTools, including both disableTools: true and ["message"]-only delivery turns), the prompt and task_completion internal events still carried SUBAGENT_COMPLETION_OUTCOME_INSTRUCTION, which instructs the model to "require continued work or a follow-up in the kept child session; report a blocker only when progress needs new user authority."

Because the turn has no execution or delegation tools, models following that instruction literally either attempt blocked tool calls (burning tokens on error round-trips) or report a spurious task failure/blocker to the user for work that already succeeded.

Changes

  • Added SUBAGENT_COMPLETION_RELAY_ONLY_OUTCOME_INSTRUCTION and rewriteSubagentCompletionReplyInstructionForRelayOnly in src/agents/subagents/completion/subagent-completion-instructions.ts so relay-only turns are instructed not to attempt tool calls or follow-up runs and to report the captured result truthfully (noting any needed follow-up for a normal turn).
  • Added adaptCompletionRelayTurnForToolSurface in src/agents/command/attempt-execution.helpers.ts (avoiding object spread in .map(...)) to rewrite both prompt and task_completion internalEvents when isSubagentAnnounceHandoff && !completionRetainsRequesterTools.
  • Wired adaptCompletionRelayTurnForToolSurface into both the CLI and embedded execution paths in src/agents/command/attempt-execution.ts.
  • Added unit tests in src/agents/command/attempt-execution.completion-relay.test.ts covering relay-only rewriting, task_completion event immutability, and preservation when requester tools are retained or the turn is not a completion handoff.

Evidence

  • Verified adaptCompletionRelayTurnForToolSurface and rewriteSubagentCompletionReplyInstructionForRelayOnly unit tests in src/agents/command/attempt-execution.completion-relay.test.ts.
  • Verified attempt-execution.ts threads the adapted prompt and internalEvents into both runCliAgent and runEmbeddedAgent when isSubagentAnnounceHandoff && !completionRetainsRequesterTools, while leaving retained-tool handoffs and non-handoff turns unchanged.
  • GitHub Actions CI (checks, oxlint, vitest) will validate the full suite on this PR.

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Nov 14, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR tailors subagent completion guidance to tool-free and message-only requester turns.

Example: A restricted completion turn receives a child result reporting three remaining lint errors.

  • Before: The instructions require continued execution despite unavailable execution tools.
  • After: The instructions require truthful reporting and identify follow-up for a normal turn, while allowing permitted message delivery.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch appears correct and resolves the prior finding, but runtime proof is absent and exact-head CI has not executed.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Restricted completion turns can attempt unavailable work or describe their own tool limitations as a problem with the completed task.
Reason: Matching instructions to the existing tool surface repairs a concrete contradiction without adding configuration or weakening authority.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR addresses a current source-level prompt mismatch, and the revised head resolves the earlier messaging restriction finding; no new correctness defect was identified.

Priority: P2
Reviewed head: c2aae4ffe23e2bba3129f34d7c843c86e15f149d

Before merge

  • Add real behavior proof - This implementation supplies helper-unit assertions and source inspection, but no shipped-entry-point run showing its new wording produces the intended restricted-relay behavior; the competing PR's traces exercise different code and wording. Redact IPs, API keys, phone numbers, and non-public endpoints from supplied traces. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Await maintainer action - A maintainer must approve the exact-head fork CI workflow awaiting execution.

Findings

None.

Tests

  • Low-value test src/agents/command/attempt-execution.completion-relay.test.ts: The helper-only constant-substitution assertions import expected wording from production and pass even if runner wiring is removed; replace them with a regression through runAgentAttempt that independently checks the resolved tool surface and resulting instructions.
  • Missing end-to-end proof: Supply redacted real-model traces through the shipped Gateway or CLI for tool-free and message-only completion relays, showing truthful child-result reporting and permitted delivery; a production-boundary regression failing on the base and passing on this head is also not shown.
Agent review details

How this fits together

The agent attempt owner receives completion prompts and internal events, resolves the permitted tool surface, and forwards matching instructions to CLI or embedded runners.

flowchart TD
  A[Child completion] --> B[Announcement prompt and event]
  B --> C[Agent attempt]
  C --> D[Completion tool policy]
  D --> E[Capability matched guidance]
  E --> F[CLI or embedded runner]
  F --> G[Requester update]
Loading

Technical review

Best possible solution:

Use the existing attempt-level tool policy to qualify shared completion guidance while preserving truthful child outcomes and permitted delivery.

Do we have a high-confidence way to reproduce the issue?

Current-main source demonstrates that restricted completion attempts receive execution-follow-up instructions; false-failure output was not independently reproduced during this read-only review.

Is this the best way to solve the issue?

Adapting guidance where the actual tool policy is resolved is proportionate, and the patch preserves existing authority and delivery owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 89c5b179fc3d.

Provenance checked

  • Completion outcome guidance changes intended behavior with a stated reason (b90cc02: Keep delegated user outcomes active after child runs stop at fixable findings.)
  • Restricted completion tool policy keeps the original intent (72f5840: Restore requester tools only where verified handoffs and runtime enforcement preserve the captured cap.)
  • Typed internal runtime context keeps the original intent (cd9913f: Keep host runtime context distinct from ordinary user messages and prevent its disclosure in replies.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit b90cc02 adds src/agents/subagents/completion/subagent-completion-instructions.ts:2 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b90cc020cada; files: src/agents/subagents/completion/subagent-completion-instructions.ts)
  • Peter Steinberger: Raw commit c891026 adds src/agents/subagents/completion/subagent-completion-instructions.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c8910267e9a7; files: src/agents/subagents/completion/subagent-completion-instructions.ts)

PR surface

Source +69, Tests +109. Total +178 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 74 5 +69
Tests 1 109 0 +109
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 183 5 +178

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: same_root_cause
Canonical: #198584
Summary: Two open PRs address the same capability-versus-guidance mismatch tracked by the linked issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Contradictory guidance affects restricted completion reporting, with a focused repair and no demonstrated widespread outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-14T05:56:43.045Z sha 776a265 :: needs real behavior proof before merge. :: [P1] [P1] Preserve messaging calls on message-only completion turns

Reviewed November 14, 2026, 12:05 PM ET / 17:05 UTC (Revision 2).

@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 14, 2026
@ElNeMeR70

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026

This branch has not been deployed

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

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Tool-free completion relay turns receive continuation instructions and report spurious task failures

1 participant