fix(recall): keep the trace id when the endpoint filters - #26
Merged
Merged
Conversation
/recall answered trace_id: null on every filtered call, which is every call any real caller makes. recallTrace rides on the returned array as a non-enumerable property, and Array.prototype.filter builds a new array. Reading it after min_importance / level / require_vec yields undefined. Measured against a live server before the fix: no filters trace_id = "7defe884-7ecf-4a54-85d1-6e4c0c94e291" min_importance trace_id = null hook-shaped trace_id = null Both hooks send min_importance and level on every call, so the id was present only in the unfiltered case nobody uses. What made it quiet is that the trace was persisted either way. recall_traces fills up with rows no caller can name — the data looks healthy from inside the DB, and get_recall_trace / validate_memory_references have nothing to be called with, so the citation contract's second half cannot run at all. The first half ships in every recall: allowed-ids and "validate generated citations against this trace before publishing." Fix is to capture the trace before the filters rather than after. Test asserts the id survives min_importance, level, and the exact shape both hooks send; without the fix those three go red and the unfiltered case still passes, which is the asymmetry that hid it. 284 passed / 0 failed. Co-authored-by: 千夏 <qianxia@clawgamers.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The bug
/recallanswerstrace_id: nullon every filtered call — which is every call any real caller makes.recallTracerides on the returned array as a non-enumerable property, andArray.prototype.filterbuilds a new array. Reading it aftermin_importance/level/require_vecyieldsundefined.Measured against a live server before the fix:
Both hooks send
min_importanceandlevelon every call, so the id was present only in the unfiltered case nobody uses.Why it stayed quiet
The trace is persisted either way.
recall_tracesfills with rows no caller can name — from inside the DB the instrumentation looks healthy.The consequence is that the citation contract only has a first half. Every recall ships:
…and then
get_recall_trace/validate_memory_referenceshave nothing to be called with, because the caller that would call them never received an id.Fix
Capture the trace before the filters instead of after.
Test
Asserts the id survives
min_importance,level, and the exact shape both hooks send. Without the fix those three go red while the unfiltered case still passes — that asymmetry is what hid it:Full suite: 284 passed / 0 failed.
🤖 Generated with Claude Code