Skip to content

fix(agent): enable empty-response retry and follow-through guardrail in streaming - #663

Merged
DonPrus merged 3 commits into
nullclaw:mainfrom
vernonstinebaker:fix/a2a-streaming-follow-through
Mar 21, 2026
Merged

DonPrus merged 3 commits into
nullclaw:mainfrom
vernonstinebaker:fix/a2a-streaming-follow-through

Conversation

@vernonstinebaker

Copy link
Copy Markdown
Contributor

Problem

Two important safeguards in src/agent/root.zig were gated on !is_streaming, which caused them to be silently skipped during A2A streaming turns:

  1. Empty-response retry — when the model returns an empty content string the agent should retry the turn (up to the configured retry limit). The !is_streaming guard caused streaming turns to exit silently on an empty reply.
  2. shouldForceActionFollowThrough — after a tool-call-only turn the agent checks whether the model neglected to produce a final prose reply and, if so, forces a follow-up turn. The !is_streaming guard suppressed this for all streaming calls, meaning tool-heavy streaming conversations could stall without a final answer.

Additionally, the actionVerbs set used by shouldForceActionFollowThrough was very small (~5 entries). Many common tool-result verbs were not matched, so the heuristic missed a wide range of stall conditions.

Changes

src/agent/root.zig

  • Remove !is_streaming guard from the empty-response retry block so streaming turns retry on blank model output.
  • Remove !is_streaming guard from the shouldForceActionFollowThrough block so streaming turns also get the follow-up guardrail.
  • Expand actionVerbs from ~5 to 25 entries covering the most common tool-result verbs (fetched, retrieved, read, wrote, created, updated, deleted, searched, listed, executed, ran, checked, found, loaded, saved, sent, posted, downloaded, uploaded, opened, closed, added, removed, set, got).

src/agent/root_test.zig (new test cases)

  • Regression tests for shouldForceActionFollowThrough covering: vikunja-mcp task-list reply, pure tool output with no prose, prose-only reply (must not trigger), and empty reply.

Testing

zig build test

All existing tests pass. New regression cases added.

Notes

  • No behaviour change for non-streaming (message/send) turns — the guards were already absent there.
  • shouldForceActionFollowThrough remains a heuristic; the expanded verb list improves coverage but is not exhaustive.

…in streaming

Both the empty-response retry and the `shouldForceActionFollowThrough`
guardrail were gated on `!is_streaming`. The A2A protocol always calls
`processMessageStreaming`, so `is_streaming` is always true for A2A
sessions — meaning neither guardrail ever fired. When the model replied
with a deferred promise ("Let me list…") but no tool call, the agent
returned that text as the final answer instead of forcing a follow-up
iteration.

Fixes:
- Remove the `!is_streaming` guard from the empty-response retry.
- Remove the `!is_streaming` guard from the follow-through guardrail.
- Expand `shouldForceActionFollowThrough` from ~5 specific verbs to ~25
  covering look/see/verify/fetch/get/retrieve/list/show/find/search/
  read/open/load/run/execute/call/use, while keeping the match
  verb-specific to avoid false-positives on conclusory phrases like
  "Let me know if…" or "I'll note that…".

Adds 9 new unit tests: 5 new positive cases and 4 new negative cases.
…llowThrough

Add 3 regression tests covering the exact phrases that caused NullClawBot
to stop prematurely when querying the Workstream Board Kanban columns:
  - 'Found the Workstream Board (project ID 4). Let me get the Kanban columns (buckets) for it.'
  - 'Let me fetch the list of projects.'
  - 'Let me look up the tasks now.'

These guard against the !is_streaming regression where the guardrail
was never reached on A2A streaming sessions.
@DonPrus
DonPrus merged commit 4455a7f into nullclaw:main Mar 21, 2026
3 checks passed
@vernonstinebaker
vernonstinebaker deleted the fix/a2a-streaming-follow-through branch March 21, 2026 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants