[FEATURE] Mods: let a turn.complete hook's text become the agent() result inside a dynamic workflow

Status Open
Reported on v2.1.294
Maintainer reply None cached
Activity 0 comments · opened Oct 9, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet (closest: #91870, the general mods thread)
  • [x] This is a single feature request (not multiple features)

Problem Statement

A mod can observe a dynamic-workflow agent's turn.complete (it carries agentId, answer, usage) and can run its own checks at that moment (a registered test command, a write-boundary audit). But the script that spawned the agent receives the agent's raw answer: the hook's returned text is display-only ("a text other than a main-loop answer's is shown beneath it"). On 2.1.294 I returned the answer plus a line [substrate] check pass · boundary clean from turn.complete; the line appears nowhere in the run's journal, in the agent's record, or in the value the script's agent() resolved to.

So a workflow script cannot branch on anything a mod proved. A review loop cannot say "ship only when the substrate's check passed"; it can only trust what the agent claims about itself.

Proposed Solution

Honour a turn.complete hook's text for workflow agents as the value agent() resolves to (and, when the call has a schema, validate the hook's text against it like the agent's own output), or add an explicit field on the result, e.g. { text, usage, result?: unknown }, that the workflow runtime hands to the script. Either way the run journal should record what the script received.

Alternative Solutions

  • Appending the mod's lines to the workflow's completion notification in prompt.submit: only the main loop sees them, never the script, and only after the whole run.
  • Having the agent itself run the check and report it: the agent can be wrong or omit it; the point of a substrate-run check is that it is not the agent's claim.
  • Running the whole plan inside the mod instead of the Workflow tool: what we do now.

Priority

High - Significant impact on productivity

Feature Category

Developer tools/SDK

Use Case Example

  1. A workflow runs writer → judge panel → refuter per item, with a registered check per writer (the mod runs it on return).
  2. The script reads each writer's result; with this feature the result carries the mod's check: pass|fail beside the writer's text.
  3. The script sends only checked items to the judges, and stops the loop when two rounds pass nothing: a stop rule based on a measured signal, not the agents' own account.

Environment: Claude Code 2.1.294, macOS 25.3, plugin hooks module (mods).

View original on GitHub ↗