Skip to content

Report a memory write or forget as unknown when the provider's error has no code - #3973

Merged
capy-ai[bot] merged 3 commits into
mainfrom
capy/uncoded-provider-errors-unknown
Nov 30, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
capy/uncoded-provider-errors-unknown

Conversation

@garrytan

@garrytan garrytan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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 HTTP 4xx other than 401 and 403 after the session opened is now unknown, with http_<status> as its code when there is one.
  • A JSON-RPC error whose data carries the provider's own code, such as { "code": "fact_not_found" }, now keeps that code, so it counts as coded and stays failed, the same as a tool error result with a code.
  • Unchanged: an error carrying the provider's code is still failed (or denied for a refusal code), a call that never reached the provider is still failed (unreachable or http_<status>), 401 and 403 are still denied, and timeouts and dropped connections are still unknown.
  • McpCallError.answered, which only marked those errors as failures, is gone, with the three places that set it.
  • What a person sees: an unknown write says it's unknown whether the provider stored the facts and that QM did not retry. It no longer says "within Nms", which read like a timeout when the provider had answered with an error. An unknown forget keeps the notebook ids of that delete and says to send the notebook ids alone to forget them now, or the same delete again once the brain's problem is fixed, because an error with no code usually comes back on every resend. Before, both said the provider changed nothing.
  • Reads, searches and brain lookups are unaffected: they don't change anything, so their errors stay failed.
  • docs/memory-providers.md: the outcome table, the forget section and its results table, and the troubleshooting rows say which errors are unknown and what to do.
Outcome table
A write or forget gets Before After
A tool error result with the provider's code (fact_not_found, invalid_params) Failed, changed nothing Unchanged
A tool error result with a refusal code, or HTTP 401/403 Denied, changed nothing Unchanged
A tool error result with no code Failed, "changed nothing" Unknown; a forget keeps the notebook ids of that delete and the reply says how to finish
A JSON-RPC error after the session opened, with the provider's code in its data Failed, without the code Failed, with the code; a forget's notebook ids are deleted
A JSON-RPC error after the session opened, with no code Failed, "changed nothing" Unknown
HTTP 4xx other than 401/403 after the session opened Failed, "changed nothing" Unknown (http_<status>)
HTTP 5xx, a dropped connection or a timeout after the session opened Unknown Unchanged
An error before the session opened Failed (unreachable or http_<status>) Unchanged

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_expired once 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_found and invalid_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:

  • Keep JSON-RPC protocol errors such as invalid params or method not found as failed. They usually come from the SDK before a tool runs, but a server can also throw them from inside a tool after it wrote.
  • Keep HTTP 4xx after 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_expired as 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 answered in a few places. Whichever lands second keeps one copy of that line and drops its answered lines.

Smaller notes from review, not changed here.

  • No unit test covers an uncoded HTTP 400 on a write or forget; the live pass below covers both.
  • Without "within Nms", a real 30-second timeout and an uncoded error give the same problem text; the recorded outcome's ms still tells them apart.
  • DELETE /v1/memory/facts doesn'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 record unknown. A write answered by a JSON-RPC error with { "code": "invalid_params" } in its data records failed with 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.

Cell Main This head
Write answered by a tool error with no code "Memory provider acme failed, so it stored nothing." "Memory provider acme didn't confirm the write, so whether it stored the facts is unknown; QM did not retry."
Write answered by HTTP 400 after the session opened "failed (http_400), so it stored nothing." "didn't confirm the write (http_400) … QM did not retry."
Forget answered by HTTP 400 after the session opened "failed to forget acme:2 (http_400), so this call changed nothing there." "didn't confirm that it forgot acme:2 (http_400), so whether it did is unknown; QM did not retry."
Delete of a notebook id and a brain ref, the forget answered by a tool error with no code The same forget of the ref alone: "failed to forget acme:2, so this call changed nothing there." "Kept 1 notebook fact because a brain didn't confirm a ref in this delete; send the notebook ids alone to forget them now, or the same delete again once the brain's problem is fixed." Deleting the notebook id alone then answered "Forgot 1 fact."
Delete of a notebook id and a brain ref, the forget answered by a JSON-RPC error with { "code": "fact_not_found" } in its data — "Forgot 1 fact." and "failed to forget acme:2 (fact_not_found), so this call changed nothing there."; a later list confirmed the notebook fact was gone
Forget of a fact gbrain doesn't have, answered by gbrain itself — "failed to forget acme:9999 (fact_not_found), so this call changed nothing there.", matching gbrain's own error row

Every forget raised an approval card first and ran only after it was approved.

Wall of shame review report

Reviewed commit: 05190a352fbc8f3b21c65ea406f7029eef1fd5ae

Round 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 commit 8cc4c325 nor the fix commit touches what they judge. Over-testing is checked by CI.

Lens Reviewer Verdict Score Assessment
Overengineering claude-opus-5-5, fresh subagent, round 1 at 8048186, carried forward Accept 96/100 A net deletion that removes the answered flag, 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.
Band-aid fixes claude-opus-5-5, fresh subagent, at this head Accept 91/100 The PR removes a band-aid: the answered guess and its SDK error-code list and status check are gone, changeFailure keeps one rule for every write and forget, and the JSON-RPC code is read with the existing envelopeOf, the same way tool error results are read.
Duplication claude-opus-5-5, fresh subagent, round 1 at 8048186, carried forward Accept 88/100 Removes a duplicate signal (answered set in three places beside code and unsent), leaving changeFailure the single owner of failed versus unknown. Its one ask, the troubleshooting row for an unknown write, is fixed in 8cc4c325.
Hand-rolling claude-sonnet-5-5, fresh subagent, round 1 at 8048186, carried forward Accept 95/100 Removes the hand-rolled answered classification and adds nothing that reimplements an SDK capability.
Non-durability claude-sonnet-5-5, fresh subagent, round 1 at 8048186, carried forward Accept 96/100 Only removes an in-memory flag from a per-call error object; no process-local state is added.
Config-matrix expansion claude-opus-5-5, fresh subagent, round 1 at 8048186, carried forward Accept 96/100 No env var, setting, schema column or outcome variant is added, and an implicit mode (the answered branch) is deleted with no reader left.
Provider drift claude-haiku-5-5 triage Not relevant — The change is in the shared MCP memory-provider path, not sandbox images or lifecycle behaviour.
God files claude-haiku-5-5 triage Not relevant — The diff shrinks mcp-client.ts, and each touched file gets a one- or two-line change.
Mismatched UI claude-haiku-5-5 triage Not relevant — No UI code or interface changes; the changed lines are docs tables and tool-result text.
Over-indexing on YC claude-haiku-5-5 triage Not relevant — The change is generic to memory providers with no YC-specific design.
Regex claude-haiku-5-5 triage Not relevant — The diff adds or changes no regular expression.
YC info leaking into public qm claude-haiku-5-5 triage Not relevant — Docs and tests use neutral examples such as acme and no organization names, hosts or internal references.
Discarded error evidence claude-sonnet-5-5, fresh subagent, at this head Accept 88/100 Keeps more evidence than it drops: a JSON-RPC envelope code now reaches McpCallError, and an uncoded error becomes unknown instead of a failed that claimed nothing changed. The only loss is "within Nms" in the uncoded unknown text, which the recorded outcome's ms still carries.
Arbitrary limits claude-haiku-5-5 triage Not relevant — No cap, timeout or retry budget is added or changed.
Explaining-away UI claude-haiku-5-5 triage Not relevant — The changed tool text tells the agent what to do next and doesn't justify a missing behaviour.
Category gate without census claude-haiku-5-5 triage Not relevant — No gate on a category is added; the outcome depends only on whether the error carries a code and whether the call was sent.
Historylessness claude-opus-5-5, fresh subagent, round 1 at 8048186, carried forward Accept 97/100 Deletes answered outright with no shim or fallback, and nothing branches on outcomes stored by older calls.
Prod-like QA claude-opus-5-5, fresh subagent, at this head Accept 86/100 Every branch the diff changes ran at this head on a real QM against real gbrain v0.60.772.0, with a main comparison: uncoded and HTTP 400 answers flip to unknown, the kept notebook id deletes on its own, a JSON-RPC data code stays failed, and gbrain's own fact_not_found stays 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.
Performance claude-haiku-5-5 triage Not relevant — No queries, loops or added I/O.
Token performance claude-opus-5-5, fresh subagent, at this head Accept 96/100 Nothing touches the system prompt or per-turn context; the kept-notebook delete reply gains about 20 tokens on a rare failure path and gives the agent a real next step, and the uncoded unknown line gets shorter.
Agent notes

Plan: exempt: diagnosed follow-up, proposed for the maintainers' decision.

  • Round 1 at 8cc4c325 (tree 55fae2bc): /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 explicit fact_not_found read as unknown and held back an approved notebook delete. The round's one fix commit 05190a35 fixes it with three of the review notes.
  • Round 2 at this head: gstack's full review of the whole diff (specialist, red team, adversarial, second-model), the touched lenses and live QA on the changed paths. The specialist, red team and adversarial readers marked nothing blocking; the second-model reader marked two findings blocking, so gstack stopped with no receipt. gstack's output at head 05190a352fbc8f3b21c65ea406f7029eef1fd5ae, tree da990b5f505e0a521252060706ed36d88631adb2: 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 with STOP_UNBOUND because the second-model reader's review row carries no tree binding.

Ruling on those two findings, in place of the receipt:

The two findings the second-model reader marked blocking on #3973 at 05190a3 are non-blocking under R12. Neither fails a test, breaks production or loses data. The first, a code in a JSON-RPC error's data counting as nothing changed even when the backend committed, is the rule this PR asks Josh and Regan to weigh in on. It goes in Review points as a question for them. The second, a session-setup JSON-RPC code being kept, exposes nothing a brain can't already cause by answering the forget call with that code. It's a named follow-up for this PR and #3957: read a JSON-RPC error's code only from the tool call, not from session setup.

  • Base: main has moved one commit since the merge base, touching none of this PR's files, and merges without conflict, so no merge-in.
  • Version: none (the repo has no version file).

…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.
@capy-ai

capy-ai Bot commented Nov 25, 2026

Copy link
Copy Markdown

@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.

capy-ai Bot added a commit to garrytan/gstack that referenced this pull request Nov 25, 2026
…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
@capy-ai
capy-ai Bot added this pull request to the merge queue Nov 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 30, 2026
@capy-ai
capy-ai Bot added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 445a661 Nov 30, 2026
32 of 33 checks passed
@capy-ai
capy-ai Bot deleted the capy/uncoded-provider-errors-unknown branch November 30, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant