Repository navigation
Report a memory write or forget as unknown when the provider's error has no code - #3973
Conversation
…code A provider that answers a write or forget with an error and no code may have written before it failed, so QM can't say nothing changed. Only an error carrying the provider's own code, or one that never reached the provider, still counts as failed. The answered flag that marked the rest as failed is gone.
… finish A provider can put its own code in a JSON-RPC error's data. QM now keeps that code, so an explicit refusal such as fact_not_found still reads as failed and no longer holds back the notebook ids in the same delete. When a brain leaves a ref unknown, the kept-notebook line now tells the person to send the notebook ids alone, or the same delete again once the brain's problem is fixed, because an uncoded error repeats on every resend. An unknown write or forget with no code no longer says "within Nms", which read like a timeout when the provider had answered with an error. The troubleshooting table now says a wrong tool name or schema mismatch on a write or forget shows up as unknown.
|
@16francej @ReganBell This PR proposes a rule for every MCP memory provider, so it needs your call before it merges. It's ready at head 05190a3. What changes: when a memory provider answers a write or a forget with an error that carries no code, QM now reports the outcome as unknown instead of saying the provider changed nothing. A provider can write and then fail, so only two things show that nothing changed: an error with the provider's own code, or a call that never reached the provider. HTTP 401 and 403 still mean denied, and reads, searches and brain lookups are unaffected. An unknown forget keeps the notebook ids from that delete, and its message says how to retry. The description's review points have one question for you: does an error carrying the provider's own code always mean nothing changed? This PR keeps main's answer, yes, and extends it to a code inside a JSON-RPC error's data. The stricter option is to count only a documented list of codes as failed and treat every other code as unknown. If neither of you objects or asks for changes before 2026-11-30 13:40 UTC (Mon Nov 30, 5:40 AM PT), we'll merge at this head as if approved. The deadline counts 48 working hours and skips Thanksgiving. If you choose a different rule, we'll change the PR to match, and that push restarts the clock with a new comment. |
…econd-model stops (GST-3814) (#4829) /gstack-ship no longer asks for every reviewer again after an edit the owner already ruled a note, and a stop on a second-model reviewer's blocker now records instead of failing with STOP_UNBOUND. Why: both forced hand-written workarounds after the final review (#4819, yc-software/qm#3973, gskills#45 and #46). Nothing to do: the fixes apply on the next /gstack-ship run. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team Review-Finding: p2/outside-voice#1 reader=outside-voice Review-Finding: p2/outside-voice#2 reader=outside-voice
When a memory provider answers a write or a forget with an error that carries no code, QM now reports whether it landed as unknown instead of saying nothing changed.
Why: a provider can write and then fail, so only an error with the provider's own code shows nothing changed. This proposes the rule for every MCP memory provider, and the maintainers decide whether it's the right one.
Nothing to do unless you disagree with the rule; the review points below list the alternatives.
What changes
changeFailure(src/memory/provider-outcome.ts) no longer treats an uncoded error from a provider that answered as a failure. A write or forget that gets a tool's error result, a JSON-RPC error, or an HTTP4xxother than401and403after the session opened is nowunknown, withhttp_<status>as its code when there is one.{ "code": "fact_not_found" }, now keeps that code, so it counts as coded and staysfailed, the same as a tool error result with a code.failed(ordeniedfor a refusal code), a call that never reached the provider is stillfailed(unreachableorhttp_<status>),401and403are stilldenied, and timeouts and dropped connections are stillunknown.McpCallError.answered, which only marked those errors as failures, is gone, with the three places that set it.failed.unknownand what to do.Outcome table
fact_not_found,invalid_params)401/4034xxother than401/403after the session openedhttp_<status>)5xx, a dropped connection or a timeout after the session openedunreachableorhttp_<status>)QM retries none of these on its own, before or after. Sending the same forget again is a new request that gbrain answers
fact_already_expiredonce a fact is gone, counted as done.Review points for the maintainers
The rule this proposes. When the forget PR landed, its Band-aid reviewer asked that QM stop reading an uncoded error as proof that nothing changed, since a provider can write and then fail. That PR kept main's rule for every MCP memory provider and left the choice to you. This PR is the smallest version of the change: only a code, or a call that never left QM, says nothing changed.
A question for you: does a code always mean nothing changed? This PR keeps main's rule that an error carrying the provider's own code changed nothing, and now applies it to a code inside a JSON-RPC error's data too. A provider that answers that way after its backend already wrote, for example a timeout waiting on its own database with a diagnostic code attached, would be reported as failed. A person could then send a write again and duplicate it when no idempotency key is mapped, and a forget that mixes in notebook ids would delete those ids. gbrain sends its codes in tool results and only for refusals that come before anything changes, so this doesn't arise with gbrain. The stricter alternative is to count only a documented list of codes as failed (the refusal codes plus each provider's pre-change codes, such as gbrain's
fact_not_foundandinvalid_params) and every other code as unknown. Should QM do that?Alternatives. Two narrower rules are possible if this one reports too much as unknown:
4xxafter the session opened as failed. The request was rejected at the HTTP layer, but QM can't tell whether an earlier step of the same call wrote.Cost of the change. A provider that fails cleanly without a code now shows as unknown, so a person is told to check rather than told nothing changed, and a forget keeps the notebook copy until the person sends the notebook ids alone or the brain's problem is fixed. gbrain attaches a code to its refusals and contract failures, so for gbrain this affects only errors it raises without one.
Follow-up: read a JSON-RPC error's code only from the tool call. QM also keeps a JSON-RPC code that arrives while the session is being set up, and the forget loop counts
fact_already_expiredas done without checking whether the forget was sent. A brain that answered session setup with that code would have a fact counted as forgotten without the forget being sent. A brain can already cause the same result by answering the forget call itself with that code, so this exposes nothing new. The follow-up reads the code only from the tool call, here and in #3957, which carries the same line.Overlap with #3957. That PR, still in review, carries a JSON-RPC error's own code into QM's error with the same line as this one, and sets
answeredin a few places. Whichever lands second keeps one copy of that line and drops itsansweredlines.Smaller notes from review, not changed here.
400on a write or forget; the live pass below covers both.msstill tells them apart.DELETE /v1/memory/factsdoesn't say that its notebook ids were kept, while the tool does. More deletes keep ids now, so the HTTP reply could carry that in a later change.Configuration, schema and prompt
No environment variable, setting, table, persisted shape or system prompt changes. The outcome recorded for the errors above moves from one existing value,
failed, to another,unknown, and two tool-result lines change wording as shown under What changes.Tests
test/memory-provider-outcomes.test.ts: an explicit write answered by a tool error with no code, and one answered by a JSON-RPC invalid-params error, now recordunknown. A write answered by a JSON-RPC error with{ "code": "invalid_params" }in its data recordsfailedwith that code; this case fails on the code before the fix. Targeted runs: the memory provider, outcome, router, tool, HTTP and connector suites pass, and typecheck, eslint, oxlint and prettier are clean.Live QA
A dev instance of QM on a real Postgres and model, against gbrain v0.60.772.0 behind a proxy that injects each answer named below, run on main and on this head.
400after the session opened400after the session opened{ "code": "fact_not_found" }in its dataEvery forget raised an approval card first and ran only after it was approved.
Wall of shame review report
Reviewed commit:
05190a352fbc8f3b21c65ea406f7029eef1fd5aeRound 2 at this head read Band-aid fixes, Discarded error evidence, Prod-like QA and Token performance again on the whole diff, the lenses triage found the fix commit touches. The other reviewed lenses carry forward from round 1 at
80481863, because neither the docs-only commit8cc4c325nor the fix commit touches what they judge. Over-testing is checked by CI.answeredflag, its error-code classification and its extra branch, adding no layer, option or config; the fix commit adds one line that reuses the existing envelope reader.answeredguess and its SDK error-code list and status check are gone,changeFailurekeeps one rule for every write and forget, and the JSON-RPC code is read with the existingenvelopeOf, the same way tool error results are read.answeredset in three places besidecodeandunsent), leavingchangeFailurethe single owner of failed versus unknown. Its one ask, the troubleshooting row for an unknown write, is fixed in8cc4c325.answeredclassification and adds nothing that reimplements an SDK capability.answeredbranch) is deleted with no reader left.acmeand no organization names, hosts or internal references.McpCallError, and an uncoded error becomesunknowninstead of afailedthat claimed nothing changed. The only loss is "within Nms" in the uncoded unknown text, which the recorded outcome'smsstill carries.answeredoutright with no shim or fallback, and nothing branches on outcomes stored by older calls.fact_not_foundstays failed. A write past the 30-second deadline, a JSON-RPC error without a data code and the HTTP routes reach the same unchanged inputs.Agent notes
Plan: exempt: diagnosed follow-up, proposed for the maintainers' decision.
8cc4c325(tree55fae2bc): /ship's full review (specialist, adversarial, second-model) and 8 lens reads. The second-model reader marked one finding blocking: a provider code in a JSON-RPC error's data was dropped, so an explicitfact_not_foundread as unknown and held back an approved notebook delete. The round's one fix commit05190a35fixes it with three of the review notes.05190a352fbc8f3b21c65ea406f7029eef1fd5ae, treeda990b5f505e0a521252060706ed36d88631adb2:NEXT: stop (a blocking finding is open after 2 rounds: name it for the owner). No stop marker was written into this body: gstack's stop step refused withSTOP_UNBOUNDbecause the second-model reader's review row carries no tree binding.Ruling on those two findings, in place of the receipt: