fix(copilot): keep a file-preview failure from stripping a tool call's arguments - #6621
Conversation
…s arguments The workspace file preview adapter runs while the tool-call frame is still on the wire, so the execution context it gets is turn-scoped and carries no toolCallId — the file delegation requires one, so resolving a path target threw on every call. The SSE handler swallows that throw and abandons the rest of the event, so the frame never registered its arguments and the call was later dispatched with an empty payload, failing schema validation. - bind the frame's own tool call id before entering the file use cases - resolve the preview target best effort, matching the preview base load - stop a preview failure from dropping the tool-call frame in the stream loop - drop the synthetic toolCallId the stream fixtures put on a turn context
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The adapter now binds the frame's Tests now use the real turn-scoped context shape (no synthetic Reviewed by Cursor Bugbot for commit b7a3e4d. Configure here. |
Greptile SummaryThis PR prevents workspace-file preview failures from discarding the underlying streamed tool-call frame.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issues identified. The changed error boundaries preserve the original tool-call frame after presentation failures, while call identity is supplied only to preview-related file operations and regression tests cover the production context shape.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/copilot/request/go/file-preview-adapter.ts | Binds streamed call identity to preview file operations and degrades target resolution without aborting the tool frame. |
| apps/sim/lib/copilot/request/go/stream.ts | Contains preview-processing failures while preserving subsequent persistence, event forwarding, and dispatch. |
| apps/sim/lib/copilot/request/go/file-preview-adapter.test.ts | Adds coverage for call-scoped identity binding and failed path resolution. |
| apps/sim/lib/copilot/request/go/stream.test.ts | Aligns stream fixtures with the lifecycle's turn-scoped execution-context shape. |
Sequence Diagram
sequenceDiagram
participant M as Mothership
participant S as Stream loop
participant P as File preview adapter
participant F as File use case
participant H as Tool event handler
M->>S: workspace_file call frame
S->>P: Process preview with turn context
P->>P: Bind frame toolCallId
P->>F: Resolve preview target
alt Resolution succeeds
F-->>P: Matching workspace file
P-->>S: Resolved preview target
else Resolution or preview fails
F--xP: Error
P-->>S: Preserve path target or throw
S->>S: Log preview failure
end
S->>H: Persist and register original frame
H-->>S: Arguments retained for dispatch
Reviews (1): Last reviewed commit: "fix(copilot): keep a file-preview failur..." | Re-trigger Greptile
Summary
workspace_filetool-call frame is still on the wire, before per-call dispatch builds a call-scoped context — so the execution context it receives is turn-scoped and carries notoolCallId. The file delegation requires one, so resolving a path-shaped preview target threw on every call.toolCallIdon a turn-scoped context, a shape the chat lifecycle never produces — that is why the tests stayed green. Removed, so they now exercise the real shape.Known-remaining, deliberately out of scope:
prePersistClientExecutableToolCallsits in the same window before the frame registers its arguments and is likewise unguarded. It must not get the same swallow — it is where a gated call is stampedawaiting_approval, so swallowing there would let a gated tool through ungated. The structural answer is to register frame state before the presentation and persistence stages, which reorders emissions the client depends on.Type of Change
Testing
bun run type-checkandbunx vitest run lib/copilot/request/go/inapps/sim(27 passing). Reverting only the two source files turns 4 of them red, including the exact error string seen in production.Checklist