Skip to content

fix(agent): log lifecycle-end completions at info/warn instead of error#101704

Closed
chenxiaoyu209 wants to merge 3 commits into
openclaw:mainfrom
chenxiaoyu209:fix/issue-101678-stop-reason-log-level
Closed

fix(agent): log lifecycle-end completions at info/warn instead of error#101704
chenxiaoyu209 wants to merge 3 commits into
openclaw:mainfrom
chenxiaoyu209:fix/issue-101678-stop-reason-log-level

Conversation

@chenxiaoyu209

Copy link
Copy Markdown
Contributor

What Problem This Solves

Successful agent run completions (stopReason=stop) were logged at console.error level, polluting error-level monitoring/alerting with false positives on every normal successful run. This also buries genuine failures in the noise.

Fixes #101678

Why This Change Was Made

The emitLifecycleEnd function unconditionally used console.error for every non-end_turn stop reason, even though stopReason=stop is a normal successful completion. The canonical terminal outcome helper (buildAgentRunTerminalOutcome) already classifies status=ok + stopReason=stop as reason=completed — but the logging path was not using this classification.

Per the AGENTS.md policy: "Agent run terminal state: normalize/merge via src/agents/agent-run-terminal-outcome.ts; do not rederive timeout/cancel precedence in projections."

User Impact

  • Before: Every successful run produces an error-level log line, triggering false alerts
  • After: Completed/cancelled runs log at info level; unusual non-error stop reasons log at warn level

Evidence

  • ClawSweeper review confirmed the bug with source-level reproduction
  • Existing agent-run-terminal-outcome.test.ts tests (14 passed) confirm the terminal outcome helper correctly classifies stopReason=stop as completed
  • agent-command.ingress-diagnostics.test.ts tests (13 passed) continue to pass with the change
  • The emitLifecycleEnd call site (agent-command.ts:2462) is only reached when no error is detected — the error path uses emitLifecycleResultError — so console.error was never the correct level for this path

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: this PR overlaps the same agent lifecycle log-severity bug as the proof-positive sibling PR, while this branch still lacks after-fix real behavior proof and has an aborted-stop status regression that makes it a weaker landing path.

Root-cause cluster
Relationship: superseded
Canonical: #101703
Summary: This PR and the sibling PR both target the same successful stopReason=stop error-severity logging bug; the sibling PR is the stronger open landing candidate because it has real behavior proof and safer abort-status handling.

Members:

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

Canonical path: Use #101703 as the canonical landing path for #101678, then close overlapping attempts once the chosen fix lands.

So I’m closing this here and keeping the remaining discussion on #101703 and #101678.

Review details

Best possible solution:

Use #101703 as the canonical landing path for #101678, then close overlapping attempts once the chosen fix lands.

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

Yes from source inspection. Current main still routes a successful meta.stopReason === "stop" lifecycle end through console.error, and the terminal outcome helper already classifies successful stop metadata as completed.

Is this the best way to solve the issue?

No. Reusing the terminal outcome helper is the right direction, but this branch is not the best landing path because it lacks live proof, overlaps the proof-positive sibling PR, and misclassifies abort-path stop metadata when deriving the helper input status.

Security review:

Security review cleared: The diff only changes in-process agent logging severity and focused tests; it does not touch credentials, dependencies, workflows, package resolution, or other supply-chain surfaces.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • steipete: GitHub path history shows repeated recent work on terminal outcome precedence and agent-command-adjacent runtime behavior, including central terminal-outcome commits and audit/agent runtime changes. (role: recent area contributor; confidence: high; commits: f53346944db0, acb0e9c1552f, b1e5c9d7fa16; files: src/agents/agent-command.ts, src/agents/agent-run-terminal-outcome.ts, src/agents/agent-run-terminal-outcome.test.ts)
  • vincentkoc: GitHub path history shows recent terminal outcome helper refactors, and local blame/release-tag provenance also points through recent Vincent Koc commits around the affected files. (role: recent terminal-outcome contributor; confidence: high; commits: 68ef80116f42, dc384393fc8b, 098b471143c1; files: src/agents/agent-command.ts, src/agents/agent-run-terminal-outcome.ts)

Codex review notes: model internal, reasoning high; reviewed against 453f5968bbca.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 7, 2026
@chenxiaoyu209

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Jul 7, 2026
@chenxiaoyu209
chenxiaoyu209 deleted the fix/issue-101678-stop-reason-log-level branch July 8, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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.

Successful run completions (stopReason=stop) logged at error severity, sometimes twice per run

1 participant