Repository navigation
fix(server): close the tool_call record when output_sanitisation blocks a response - #1687
Merged
Merged
Conversation
…ks a response A response_action: block refusal returned before the dispatch recorded its completion, so a call whose upstream DID run left only a policy_decision: no persisted tool_call row, an SSE started event with no completion, and no tool-call history entry. handleCallToolVariant and the legacy handleCallTool now close the call on a block: the history entry and the tool_call completion (status error, error_class proxy_policy) carry the fixed block message, never the response. The call_tool_* path also emits its internal_tool_call record. The Spec 107 audit tool_call line was already written by the block's policy_decision; the completion's audit write is the existing deduped no-op. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
a64da04
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://19f38208.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-sanitisation-block-compl.mcpproxy-docs.pages.dev |
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 39398597766 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…k-completes-tool-call
… block Direct routing (#1685) returned applyOutputSanitisation's block result before emitting the call's completion. It now emits the same error tool_call (error_class proxy_policy, block message only) as the call_tool_* paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dumbris
enabled auto-merge (squash)
October 20, 2026 09:17
Dumbris
added a commit
that referenced
this pull request
Oct 20, 2026
Follow-up to #1687: reattach the doc comment that the sanitiser-block change left detached from recordToolCallAt.
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
output_sanitisationblocks a response (response_action: block), the call_tool_* handlers returned before recording the call's completion. The upstream call did run (side effects may have happened), yet only apolicy_decisionwas persisted: notool_callactivity row (started events are not persisted), an SSEstartedevent with no completion, and no tool-call history entry.handleCallToolVariant, the legacyhandleCallTooland direct routing mode (makeDirectModeHandler, added by #1685) now close the call on a block:Errorset to the block message andResponsecleared, so the blocked payload is never stored.tool_callcompletion is emitted with statuserror,error_class: proxy_policyandfault_domain: proxy. It carries the fixed block message, never the response. On call_tool_* paths theinternal_tool_callrecord is emitted as well.recordOutputBlockedfollows the convention of the code_execution sub-call block path, which already closed its record this way.Counting / audit check
policy_decisionalready writestool_call outcome:blocked reason:output_sanitisation(isPostDispatchBlockKey). The completion's audit write is the existing deduped no-op (toolCallWritten), so the audit log still has one line per attempt.policy_decision, the upstream-attempt bucket was counted at dispatch, and activation is not recorded.storage.CountsAsCall): thepolicy_decision(blocked) and the newtool_call(error) both count as failed calls. One blocked attempt therefore counts as two failed calls in those totals. The code_execution sanitisation block and the generation-changed refusal pair already counted this way. Separating them needs the post-dispatch block key on thepolicy_decisionrecord, so that is left for a follow-up.Direct mode
After #1685 merged, origin/main was merged into this branch and the direct-mode block now emits the same error
tool_callcompletion. Direct mode keeps no tool-call history.Tests
TestCallToolVariant_SanitisationBlockRecordsToolCallCompletionandTestLegacyCallTool_SanitisationBlockRecordsToolCallCompletiondrive a real in-process upstream that returns an AWS key with block mode on. Each asserts one persistedtool_callwith statuserroranderror_classproxy_policy, thepolicy_decisionbeside it, and the secret absent from every activity record.TestDirectMode_SanitisationBlockRecordsToolCallCompletionasserts the same for direct mode. All three failed before the fix (notool_callrecord).TestRecordOutputBlocked_HistoryCarriesBlockMessageNotResponseasserts the history entry carries the block message and no response. The direct-routing fixture's incarnation guard drops all history writes, so this is tested on the helper.go test -race ./internal/server/with the unit-tests.yml-skipregex: pass.golangci-lintv2 (.github/.golangci.yml), bare and--build-tags server, over./internal/server/...: no issues in changed files. Six existing staticcheck findings remain in untouched test files.🤖 Generated with Claude Code