Skip to content

fix(harness): compact compose mutation results - #998

Closed
mfpiccolo wants to merge 4 commits into
mainfrom
fix/compact-compose-results
Closed

fix(harness): compact compose mutation results#998
mfpiccolo wants to merge 4 commits into
mainfrom
fix/compact-compose-results

Conversation

@mfpiccolo

@mfpiccolo mfpiccolo commented Aug 29, 2026

Copy link
Copy Markdown

Summary

Prevent large function results from unnecessarily inflating Harness transcripts and model context.

Harness previously serialized function results into model-visible content while also persisting the complete raw value in structured details. This duplicated successful responses in durable session history and increased context-assembly payload size, trace volume, and compaction pressure.

This change introduces function-agnostic safeguards. It does not special-case Compose or rewrite another function’s contract.

Changes

Bound model-visible function results

All function results now have a hard model-visible text limit of 12,000 characters.

Oversized results end with an explicit marker:

…[function result truncated; request a narrower result or use a diagnostic function]

The complete rendered result, including the marker, remains within the limit. This applies uniformly to every iii function.

Stop duplicating successful results

Raw function values remain available during execution for processing that needs them, including:

  • post-function hooks
  • contract handling
  • discovery filtering

After that processing completes, successful results are persisted with details: null.

The model-visible content remains in the transcript, but the complete raw response is no longer stored beside it as a second copy.

Bound failure metadata

Failed function results may require structured metadata for diagnostics.

Failure details are retained when small. Oversized failure details are replaced with a bounded representation containing:

  • truncated: true
  • a 2,000-character JSON preview

Model-visible invocation error text is also subject to the general 12,000-character limit.

Cover deferred function completions

Deferred function results previously constructed transcript messages directly and bypassed the normal append path.

The same bounds and persistence policy now apply to:

  • externally delivered deferred results
  • released held functions
  • deferred function denials
  • deferred agent-spawn results

Remove unnecessary details before context assembly

Before transcript messages are sent to the context manager, ordinary function-result details are cleared from the model-facing copy.

Permission-denial details remain available because provider adapters use that structured information to communicate denials.

Architectural scope

Harness remains function-agnostic.

This PR does not:

  • inspect function IDs
  • special-case Compose
  • rewrite Compose responses
  • replace another function’s response schema
  • make assumptions about worker-specific result structures

Functions remain responsible for returning appropriately designed response payloads. These Harness safeguards provide a general upper bound and prevent duplicate persistence when a function legitimately—or accidentally—returns a large result.

Any change to Compose’s native mutation response must be made where the Compose functions are implemented and registered.

Result

Before this change, a large successful response could be retained twice:

  1. Serialized into model-visible content.
  2. Stored again as the complete structured details value.

After this change:

  • model-visible result text is bounded
  • successful raw details are not duplicated
  • failure metadata is bounded
  • context assembly does not transport unnecessary result details
  • immediate and deferred completion paths follow the same policy

Validation

  • cargo test --manifest-path harness/Cargo.toml --lib
    • 453 tests passed
  • cargo clippy --manifest-path harness/Cargo.toml --all-targets -- -D warnings
  • cargo fmt --manifest-path harness/Cargo.toml
  • git diff --check

Regression coverage includes:

  • bounded generic function results
  • explicit truncation markers
  • removal of duplicate successful-result details
  • bounded failure details

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview Aug 29, 2026 8:46pm
workers-tech-spec Ready Ready Preview Aug 29, 2026 8:46pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 69 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

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