Skip to content

Measure execute result size once per result object - #1866

Merged
RhysSullivan merged 2 commits into
mainfrom
dedupe-result-stringify
Aug 30, 2026
Merged

Measure execute result size once per result object#1866
RhysSullivan merged 2 commits into
mainfrom
dedupe-result-stringify

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

The span size probe serializes the whole returned value to count its characters. The same result object was walked again for every extra span it was stamped onto: an operator-approved (autoApprove) run paid two identical size walks (inner inline span plus outer pausable span), and each retried resume that replays a settled outcome paid another. The measurement record is now cached per result object, so a large result pays one size walk total.

Walks a large result paid between engine completion and response, before vs after:

  • autoApprove execute: 3 (2 identical size walks + 1 preview render) -> 2 (1 + 1)
  • resume retry replaying a settled outcome: 2 per retry -> 1 per retry (preview only)
  • plain MCP execute/resume: 2 -> 2 (unchanged; see below)

The remaining two walks on the plain path serialize to different strings by design: the size metric is a compact JSON length, the text preview is pretty-printed with indent 2. Neither can be derived from the other, so they cannot be collapsed without changing span attributes or response bytes. The suspected duplicate in the MCP host (toMcpOutputResult vs toMcpResult) is not real: the two formatting calls are mutually exclusive branches, and a test now pins that the host renders the result exactly once with or without emit() output.

Response text, structured content, truncation behavior, and span attribute values are byte-identical; tests pin the preview format (including non-ASCII and truncation) and assert walk counts via an instrumented fixture.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 30, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing f835495 Commit Preview URL

Branch Preview URL
Aug 30 2026, 02:32 AM

@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 30, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud f835495 Aug 30 2026, 02:33 AM

@pkg-pr-new

pkg-pr-new Bot commented Aug 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1866

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1866

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1866

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1866

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1866

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1866

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1866

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1866

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1866

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1866

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1866

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1866

executor

npm i https://pkg.pr.new/executor@1866

commit: f835495

@RhysSullivan
RhysSullivan marked this pull request as ready for review August 30, 2026 02:35
@RhysSullivan
RhysSullivan merged commit 21119da into main Aug 30, 2026
43 of 44 checks passed
@RhysSullivan RhysSullivan mentioned this pull request Aug 30, 2026
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