Skip to content

fix(llm): log a Stop as a stop, not as three errors - #7313

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/rc18-stop-not-error
Nov 12, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
kovtcharov:kalin/rc18-stop-not-error

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Every Stop pressed while the model was still silent wrote three ERROR
lines to gaia.log, one each from the Lemonade client, the SDK and the
agent loop, so 30 stops buried real failures under 90 errors in a
troubleshooting report. A stop is now one INFO line at each layer, and a
real streaming failure is still logged as an error.

stopped_by_user() recognises a StreamCancelledError or an error raised
while handling one; the three log sites use it to pick the level. What is
raised, and how the turn ends, is unchanged.

Closes #7306

Test plan

  • python -m pytest tests/unit/test_stop_is_not_an_error.py and the cancel, retry and streaming suites (178 pass)

Every Stop pressed while the model was still silent wrote three ERROR
lines to gaia.log, one each from the Lemonade client, the SDK and the
agent loop, so 30 stops buried real failures under 90 errors in a
troubleshooting report. A stop is now one INFO line at each layer, and a
real streaming failure is still logged as an error.

stopped_by_user() recognises a StreamCancelledError or an error raised
while handling one; the three log sites use it to pick the level. What is
raised, and how the turn ends, is unchanged.

Closes #ISSUE
@github-actions github-actions Bot added chat Chat SDK changes llm LLM backend changes tests Test changes performance Performance-critical changes agents labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

Pressing Stop while the model is still silent now logs one INFO line at each layer instead of three ERROR lines, so troubleshooting reports stop burying real failures under user stops. Only the log level changes; what gets raised and how the turn ends stay the same, and a real streaming failure is still logged as an error. The tests check both.

  • Follow-up (not blocking): the non-streaming path still logs a Stop as errors. A Stop during a busy-server wait reaches the SDK and agent loop through two catch-alls this PR didn't touch, so non-streaming runs still put error lines in the log.

Real-world evidence

N/A: no evidence bundle was produced for this run. The change only affects log levels and touches no CLI, API, MCP or UI output, so this verdict rests on static review and the PR's unit tests.

🔍 Technical details

Issues

🟡 Follow-up: Log a Stop on the non-streaming path as a stop too (src/gaia/chat/sdk.py:597, src/gaia/agents/base/agent.py:11922)
_wait_while_busy and _unless_stopped (lemonade_client.py:5981, :6018) raise StreamCancelledError from the model-load wait. That wait runs ahead of non-streaming calls too (lemonade_client.py:9047). On that path, send_messages logs Error in send_messages and the agent loop logs Unexpected error calling LLM at ERROR level, the same noise this PR removes from streaming. The fix is the same stopped_by_user(e) guard used at the three streaming sites. Fix it here or file an issue before merge.

🟢 __context__ makes the check broad (src/gaia/llm/retry.py:479)
Because stopped_by_user also follows __context__, any error raised while a StreamCancelledError is being handled counts as a stop, including an unrelated bug in cleanup code. The docstring states this and it only changes a log level, so it's acceptable. If you want the narrower check, follow only __cause__; every wrap site in the PR uses raise ... from e.

Strengths

  • One shared predicate with cycle protection, applied at all three streaming log sites, rather than three hand-written isinstance checks.
  • test_a_real_streaming_failure_is_still_an_error guards against the obvious over-correction of hiding real failures.
  • Scope matches the description: logging only, with raise and turn-ending behaviour unchanged.

A Stop during the busy-server wait also reaches non-streaming calls,
where the SDK and the agent loop still logged it as two errors. Both now
log it at INFO, as the streaming path does; a real failure stays an
error.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

A Stop on the non-streaming path is now logged as a stop too, and the failed setup check comes from a test race, not this change.

  • Non-streaming path: took the follow-up here. The SDK's send_messages and the agent loop's catch-all now log a Stop at INFO, as the streaming sites do. A real failure is still logged as an error. Added a test for each site.
  • The broad __context__ check: kept it. A wrap site that raises inside an except block without from still chains the Stop only through __context__, so following __cause__ alone would put those Stops back in the error log. This check only changes a log level.
  • Setup journey (ubuntu): only the Arabic run of "the cloud path greys the gateway" failed. The English run of the same test passed in the same job. The test reserves a closed port for an unreachable gateway, and the gateway read as reachable, which fits another parallel test taking that port. This PR only changes log levels in the model-call error handlers and touches no setup, network or UI code. The new push re-runs it.

A cause chain that loops back must end, and an error raised from another
failure while a Stop is being handled must still be logged as an error.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 12, 2026
Merged via the queue into amd:main with commit ee484d4 Nov 12, 2026
54 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/rc18-stop-not-error branch November 12, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents chat Chat SDK changes llm LLM backend changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logs: every Stop writes three ERROR lines

2 participants