Fix MCP approval resuming#50
Conversation
Greptile SummaryThis PR fixes three interrelated bugs in the MCP approval-resuming flow: org ID partition mismatches caused resume to look in the wrong database partition; the tool loop continued after parking (sending a continuation to the model), producing a stray trailing assistant message that poisoned the resume transcript; and replayed
Confidence Score: 4/5The changes are targeted correctness fixes for the MCP approval flow with comprehensive test coverage; no regressions expected in unrelated paths. All three bugs are fixed at their root: the org-partition mismatch is resolved by sharing a single resolver; the trailing assistant-message problem is fixed by the stop_loop signal; and stale mcp_approval_request history items are now dropped before upstream forwarding. Each fix is covered by a dedicated unit or integration test. No files require special attention; the core logic changes are in responses_pipeline.rs, chat.rs, runner.rs, and executor.rs, all of which read clearly and are well-tested. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Route as chat.rs
participant Runner as ToolLoopRunner
participant Executor as McpExecutor
participant DB as mcp_pending_approvals
Note over Client,DB: Park turn
Client->>Route: POST /v1/responses
Route->>Runner: wrap_streaming
Runner->>Executor: execute(mcp_call)
Executor->>DB: "insert(org_id=resolve_request_org())"
Executor-->>Runner: "ToolCallResult stop_loop=true"
Runner-->>Client: mcp_approval_request + response.completed
Note over Client,DB: Resume turn
Client->>Route: POST /v1/responses + mcp_approval_response
Route->>Route: resolve_request_org() same helper
Route->>DB: take_by_id_and_org(approval_id, org_id)
DB-->>Route: parked call row
Route->>Route: resume_mcp_approvals rewrites input
Route->>Runner: wrap_streaming rewritten input
Runner-->>Client: real tool result
Reviews (1): Last reviewed commit: "Fix MCP approval resuming" | Re-trigger Greptile |
No description provided.