Skip to content

demo: its harness wrappers declare modelCalls up front (one chat span per model call) - #16

Merged
pranaygp merged 1 commit into
mainfrom
fix/demo-model-calls
Oct 19, 2026
Merged

pranaygp merged 1 commit into
mainfrom
fix/demo-model-calls

Conversation

@pranaygp

Copy link
Copy Markdown
Collaborator

On the demo, every model call shows up twice in its Agent Runs trace: an empty chat span (finish reason unknown, no usage) next to the real one. The turn view in Agent Runs hides the empty span, but the raw trace has two chat spans per step. For example, a Pi tool turn has 2 steps and 4 chat spans.

Cause: the demo's harness wrappers (byHands in lib/hands.ts, lazyHarness in lib/sessions.ts) build the real harness on its first drive. They declared only name and lanes up front. durable-harness's tracing reads modelCalls from the harness when a drive starts, before that build. With no modelCalls on the wrapper, it treated each demo harness as an effects harness and recorded a chat span from every model effect, on top of the call the harness records itself.

Fix: every harness the demo wraps records its own model calls (modelCalls: 'self'): Pi, fx, the hybrid harnesses, the CLIs and the reference CLI behind the Gateway proxy, and the AI SDK.

  • Both wrappers now take what's known up front: UpFront, which is lanes and modelCalls.
  • Each call site declares modelCalls: 'self'.
  • A wrapper warns if the harness it builds says something different, so a harness added later can't drift silently.

The package is unaffected. Its own wrapper, pi() in durable-harness/pi, already declares modelCalls: 'self'.

Tests: lib/hands.test.ts adds one case: the wrapper declares modelCalls before its first build, and warns when the built harness disagrees. Demo typecheck passes, and check-public passes.

Check on this PR's preview: a Pi tool turn should have one chat span per step (2 steps, 2 chat spans) and the same usage in Agent Runs.

🤖 Generated with Claude Code

… per model call)

The demo's harness wrappers (`byHands`, `lazyHarness`) build the real harness on its first drive, and declared only `name` and `lanes` up front. durable-harness's tracing reads `modelCalls` from the harness when a drive starts, before that build, so it took every demo harness for an `effects` one: each model call got an extra empty `chat` span from its `model` effect (finish reason unknown, no usage) next to the one the harness records itself. Agent Runs' turn view hid it; the raw trace showed two chat spans per step.

Every harness the demo wraps records its own model calls (`modelCalls: 'self'`), so the wrappers now declare it up front (`UpFront`: `lanes` and `modelCalls`), and warn when the harness they build says otherwise.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
harness-on-world Ready Ready Preview, v0 Oct 19, 2026 6:34pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
durable-fx-example Skipped Skipped v0 Oct 19, 2026 6:34pm UTC

@pranaygp

Copy link
Copy Markdown
Collaborator Author

Checked on this PR's preview (f05a293): a Pi tool turn (wrun_01M5AQ3KQA0KRKK9B9Y700ZYX2) and a Claude Code tool turn (wrun_01M5AQ3QPGCQEPT4CVMKH197WJ) each have 1 invoke_agent span, 2 agent.step spans, 2 chat spans and 1 execute_tool span, with no empty chat spans. Before this change, the same Pi turn had 4 chat spans. In Agent Runs both show one completed turn with the tool call and usage.

@pranaygp
pranaygp merged commit fb056a3 into main Oct 19, 2026
14 checks passed
@pranaygp
pranaygp deleted the fix/demo-model-calls branch October 19, 2026 18:42

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – harness-on-world — f05a2935 Deployed Oct 19, 2026 by vercel[bot]
Preview – durable-fx-example — f05a2935 Deployed Oct 19, 2026 by vercel[bot]
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.

2 participants