[superlog] Log unknown custom tool names and defer failure to allow model self-correction#245
Open
superlog-app[bot] wants to merge 1 commit into
Open
[superlog] Log unknown custom tool names and defer failure to allow model self-correction#245superlog-app[bot] wants to merge 1 commit into
superlog-app[bot] wants to merge 1 commit into
Conversation
…odel self-correction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the investigation agent calls a tool name the runtime doesn't recognize (a hallucinated or mistyped tool name), the worker was failing the run immediately — before the model had a chance to see the error response that was just sent back to it in the same collect pass. This meant investigations that ran for 15+ minutes could be permanently aborted on a single naming mistake.
Root cause
syncRunningAgentRuncheckedsnapshot.unknownCustomTools.length > 0and calledfailAgentRunbefore theshouldDeferSteeringguard. BecausecollectManagedAgentRunsends the error acks for unknown tools in the same pass that populatessnapshot.unknownCustomTools, the model had not yet received the error response ("unknown tool: X") at the moment the run was killed. On the very next tick,snapshot.unknownCustomToolswould have been empty (the tool is now acked in the stream) and the run would have continued normally — but it never got that tick.Additionally, the specific tool names were stored only in the DB failure summary, not in any structured log field, making the comment "so we can audit them later" impossible to satisfy from logs alone.
Remediation
Two changes, both in
apps/worker/src/agent-runs/sync.ts:Move the check after the DB update —
cumulativeRuntimeMinutesandlastSyncedAtare now current before we touch this path.Emit a WARN with the tool names, then defer instead of failing — when
sentToolAckCount > 0(always true for unacked unknown tools), the error ack was sent this pass and the model will see it on its next event. We return early (before steering/completion) and let the model self-correct. Persistent hallucination is caught by the existing wall-clock budget. The only code path that still callsfailAgentRunis thesentToolAckCount === 0edge case, which shouldn't occur in practice but guards against unexpected regressions.The structured
unknown_tool_namesfield in the WARN makes tool-name auditing possible directly from log queries without a DB lookup.Incident on Superlog
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
Prevents premature run failures when a model calls unknown custom tools by logging the tool names and deferring failure so the model can self-correct on the next tick.
unknown_tool_namesand return early to let the model self-correct.Written for commit 05e541e. Summary will update on new commits.