GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — mcpx: per-call 'call' frames in the exec stream (#1927 Approach B item 2) by dezren39 · Pull Request #2615 · developing-today/code Conversation
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 31 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e505aa2c5
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| start := time.Now() | ||
| res, err := s.reg.Call(ctx, req.Server, req.Tool, cc, args) | ||
| dur := time.Since(start).Truncate(time.Millisecond) | ||
| s.reportCallFrame(ctx, req.Server, req.Tool, args, start, err) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Treat MCP isError results as failed call frames
When an upstream tool returns isError: true, Registry.Call returns its result envelope with a nil Go error, so this reporting call produces ok: true with no error even though the generated client throws ToolError. This makes failed tool invocations appear successful to stream consumers. Inspect the result's failure state when building the frame, as the path-per-tool response already does with resultFailed(res), and apply the same correction to that handler's reporting call.
AGENTS.md reference: pkgs/mcpx/AGENTS.md:L80-L80
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aa5a242: reportCallFrame now takes the call result and, when the Go error is nil but resultFailed(res) reports isError, marks the frame failed with an isError error string — applied at both call sites (/v1/call and /v1/call/{server}/{tool}). Covered by TestReportCallFrameMarksIsErrorResultsFailed in internal/daemon/call_frames_test.go.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| start := time.Now() | ||
| res, err := s.reg.Call(ctx, req.Server, req.Tool, cc, args) | ||
| dur := time.Since(start).Truncate(time.Millisecond) | ||
| s.reportCallFrame(ctx, req.Server, req.Tool, args, start, err) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Emit call frames from the input-report execution path
For remote CLI runs with an elicitation broker configured, internal/cli/exec.go sets MCPX_INPUT=report, which the generated client sends as x-mcpx-input. These requests return through handleCallReporting at lines 1062–1064 before reaching this new reporting call. That handler executes Registry.CallReporting without emitting a call frame, so even ordinary successful tool calls from these daemon-executed runs are entirely absent from the stream. Report completed calls from that branch as well.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aa5a242: handleCallReporting now calls reportCallFrame with the run context when CallReporting completes, so calls on the input-report path emit call frames too. Covered by TestHandleCallReportingEmitsCallFrame in internal/daemon/call_frames_test.go.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| for _, t := range s.reg.Tools([]string{server}) { | ||
| if t.Tool == tool { | ||
| d := destructiveHint(t.Annotations) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Resolve the exact server before selecting call annotations
When one server's namespace matches another server's name, Registry.Tools([]string{server}) can return tools from both servers because its filter accepts either name or namespace. For example, with server a using namespace b and server b using namespace c, a call to server b executes that server because Registry.Pool prioritizes exact names, but this loop can select server a's identically named tool first. Consequently, a destructive call can be reported with destructiveHint: false from an unrelated tool. Resolve the server identity using the same precedence as call dispatch and match that identity when selecting annotations.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in aa5a242: reportCallFrame now selects annotations with dispatch precedence — exact server name first (ToolInfo.Server), namespace only as fallback (ToolInfo.Namespace) — matching Registry.Pool. Covered by TestReportCallFrameResolvesExactServerBeforeNamespace, including the a-namespace-b / b-namespace-c collision.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- isError tool results now produce failed call frames (resultFailed),
on both /v1/call and /v1/call/{server}/{tool}
- handleCallReporting reports completed calls, so exec runs whose
calls ask questions still emit call frames
- destructiveHint annotations are resolved with dispatch precedence:
exact server name before namespace, so a namespace that equals
another server's name cannot lend it wrong annotations
- daemon tests for all three
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: aa5a24297b
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| r.mu.Lock() | ||
| sink, ok := r.sinks[runID] | ||
| r.mu.Unlock() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Drain in-flight call reports before closing the stream
When a script times out or is cancelled while a tool request is finishing, ReportCall can obtain this sink just before RunWith unregisters it and returns. Deleting the map entry does not invalidate the captured closure, so the reporter can subsequently emit a call after the terminal frames—or write through execStream's HTTP response writer after its handler has returned. The sink mutex only serializes writes; it does not prevent this lifetime race. Coordinate unregistering with in-flight reports and close call-frame delivery before emitting the terminal frames.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 78cf55a. CallRegistry sinks are now lifetime-tracked entries (callSink{closed, wg}): ReportCall counts itself in-flight under the registry lock, and unregister — now idempotent — closes the entry to new reports and waits for in-flight deliveries to finish. RunWith calls unregister explicitly after the run returns and before emitting any terminal (result/error/end) frames, with the defer kept only as a safety net. So a report already being delivered lands in order ahead of the terminal frames, a report that starts after the close is dropped, and nothing can write to the stream after end. Regression test: TestCallRegistryUnregisterDrainsInFlightReports (blocks a sink mid-delivery and asserts unregister waits, the frame lands, and later reports drop).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| start := time.Now() | ||
| res, err := s.reg.Call(ctx, req.Server, req.Tool, cc, args) | ||
| dur := time.Since(start).Truncate(time.Millisecond) | ||
| s.reportCallFrame(ctx, req.Server, req.Tool, args, start, res, err) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Include generated batch calls in per-call reporting
When a daemon-executed script uses the supported global batch(...) helper, its tool invocations produce no call frames. The generated helper in internal/codegen/emit.go:1330–1339 posts to /v1/batch without forwarding X-Mcpx-Run, and handleBatch invokes Registry.Call directly at server.go:1190, bypassing the newly instrumented single-call handlers. Consequently, stream consumers miss all calls made through either sequential or parallel batches. Forward the run ID from the helper and report each completed batch item as well.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 78cf55a. Two parts: (1) the generated batch() helper in internal/codegen/emit.go now forwards "x-mcpx-run": env("MCPX_RUN"), matching __call — handleBatch already places that header into the call context via withRun; (2) handleBatch's runOne now calls s.reportCallFrame(ctx, server, tool, args, start, res, err) for every completed item, so sequential and parallel batch items each produce a call frame (including the isError→failed mapping, via the shared reporting path). Pre-dispatch validation failures stay unreported, matching the single-call handler's behaviour. Regression test: TestHandleBatchEmitsCallFrames.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…(Codex round 2 on #2615) CallRegistry sinks are now lifetime-tracked entries: unregister closes an entry to new reports and waits for in-flight deliveries, and RunWith closes call delivery explicitly before its terminal frames, so a call frame can never land after result/end. handleBatch reports each completed item via reportCallFrame and the generated batch() helper forwards x-mcpx-run, so batch calls appear in the exec stream like single calls.
…frames # Conflicts: # pkgs/mcpx/docs/exec.md # pkgs/mcpx/internal/daemon/routes_exec.go # pkgs/mcpx/internal/execsvc/execsvc.go
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.