harness-pi drops approved builtin tool results from continued streams
Description
After a builtin tool such as bash is approved, Pi executes it and emits a toolResult message, but HarnessAgent.continueStream().fullStream does not emit the corresponding tool-result or tool-error part.
Versions
- @ai-sdk/harness: 1.0.75
- @ai-sdk/harness-pi: 1.0.77
Reproduction
- Create a Pi HarnessAgent with bash active and permissionMode set to allow-edits.
- Start a turn that calls bash and drain the tool-approval-request.
- Approve it through continueStream and drain fullStream.
- Observe that Pi emits message_end with role toolResult and the command runs, but fullStream omits its result.
The approval continuation appears to add the builtin call ID to settledHostToolCallIds before replay, so the replay filter discards the first real builtin tool result.
Expected
The continued stream emits one tool-result or tool-error for the approved builtin call.
Identify issue type
Identified as Bug
Confidence: High
Rationale
This is a concrete failure in existing stream-continuation behavior: an executed and approved built-in tool result is dropped instead of being emitted.
Evidence
- After approving a built-in Pi tool such as
bash, the command executes and Pi emits atoolResultmessage. HarnessAgent.continueStream().fullStreamincorrectly omits the correspondingtool-resultortool-errorpart.- The report provides affected package versions, reproduction steps, expected behavior, and a suspected replay-filter cause.
Bug Reproduction - AI SDK 7
Bug was reproduced.
Branch: main
PR: successful reproduction pull request
Details
- The approved
bashcommand exited successfully and Pi emitted a matchingmessage_endtool-result containingissue-19156, butcontinueStream().fullStreamemitted no matchingtool-resultortool-error, preventing consumers from observing the execution outcome. - Expected exactly one continued-stream tool outcome for the approved builtin call; observed zero.
packages/harness/src/agent/internal/run-prompt.tsadds the approved builtin call ID tosettledHostToolCallIdsbefore replay, and the replay filter consequently discards its real tool result.- The issue persists on current
main, withpackages/harness/package.jsonat 1.0.77 andpackages/harness-pi/package.jsonat 1.0.79, so upgrading from the reported1.0.75/1.0.77versions does not resolve it. examples/ai-functions/src/reproduction/issue-19156-harness-pi-approved-builtin-result.tsreproduces the failure using Pi,permissionMode: 'allow-edits', builtinbash, a local just-bash sandbox, and an Anthropic live model.
Relevant Documentation
- https://github.com/vercel/ai/blob/main/packages/harness-pi/README.md
Bugfix - AI SDK 7
Created bugfix and opened PR: #19160
Root Cause
runPrompt marked builtin approval call IDs as settled host tool calls, causing the replay filter to discard the builtin's first real result. The live reproduction and a focused failing regression test confirmed this path.
Summary
Separated builtin approval replay tracking from host tool result tracking so replayed calls and approval requests remain suppressed while genuine builtin outcomes are emitted. Added a patch changeset for @ai-sdk/harness.
Testing
Added regression coverage verifying that continued builtin approvals suppress replayed input events, submit approval once, and emit exactly one provider tool result.
:rocket: Published in:
| Package | Version |
|---|---|
ai |
7.0.77 github npm |
@ai-sdk/alibaba |
2.0.34 github npm |
@ai-sdk/amazon-bedrock |
5.0.61 github npm |
@ai-sdk/angular |
3.0.77 github npm |
@ai-sdk/anthropic |
4.0.41 github npm |
@ai-sdk/anthropic-aws |
2.0.33 github npm |
@ai-sdk/assemblyai |
3.0.29 github npm |
@ai-sdk/azure |
4.0.48 github npm |
@ai-sdk/baseten |
2.1.13 github npm |
@ai-sdk/black-forest-labs |
2.0.30 github npm |
@ai-sdk/bytedance |
2.0.32 github npm |
@ai-sdk/cartesia |
3.0.24 github npm |
@ai-sdk/cerebras |
3.0.35 github npm |
@ai-sdk/code-mode |
1.0.34 github npm |
@ai-sdk/cohere |
4.0.29 github npm |
@ai-sdk/deepgram |
3.0.29 github npm |
@ai-sdk/deepinfra |
3.0.35 github npm |
@ai-sdk/deepseek |
3.0.31 github npm |
@ai-sdk/elevenlabs |
3.0.30 github npm |
@ai-sdk/fal |
3.0.30 github npm |
@ai-sdk/fireworks |
3.0.38 github npm |
@ai-sdk/fish-audio |
3.0.7 github npm |
@ai-sdk/gateway |
4.0.62 github npm |
@ai-sdk/gladia |
3.0.29 github npm |
@ai-sdk/gmicloud |
3.0.6 github npm |
@ai-sdk/google |
4.0.50 github npm |
@ai-sdk/google-vertex |
5.0.61 github npm |
@ai-sdk/groq |
4.0.30 github npm |
@ai-sdk/harness |
1.0.85 github npm |
@ai-sdk/harness-acp |
1.0.23 github npm |
@ai-sdk/harness-claude-code |
1.0.88 github npm |
@ai-sdk/harness-cline |
1.0.12 github npm |
@ai-sdk/harness-codex |
1.0.87 github npm |
@ai-sdk/harness-deepagents |
1.0.85 github npm |
@ai-sdk/harness-grok-build |
1.0.22 github npm |
@ai-sdk/harness-opencode |
1.0.86 github npm |
@ai-sdk/harness-pi |
1.0.87 github npm |
@ai-sdk/huggingface |
2.0.35 github npm |
@ai-sdk/hume |
3.0.29 github npm |
@ai-sdk/klingai |
4.0.31 github npm |
@ai-sdk/langchain |
3.0.77 github npm |
@ai-sdk/llamaindex |
3.0.77 github npm |
@ai-sdk/lmnt |
3.0.29 github npm |
@ai-sdk/luma |
3.0.30 github npm |
@ai-sdk/mcp |
2.0.36 github npm |
@ai-sdk/minimax |
3.0.17 github npm |
@ai-sdk/mistral |
4.0.32 github npm |
@ai-sdk/moonshotai |
3.0.37 github npm |
@ai-sdk/open-responses |
2.0.30 github npm |
@ai-sdk/openai |
4.0.46 github npm |
@ai-sdk/openai-compatible |
3.0.35 github npm |
@ai-sdk/otel |
1.0.77 github npm |
@ai-sdk/perplexity |
4.0.31 github npm |
@ai-sdk/policy-opa |
1.0.77 github npm |
@ai-sdk/prodia |
2.0.30 github npm |
@ai-sdk/provider-utils |
5.0.29 github npm |
@ai-sdk/quiverai |
2.0.29 github npm |
@ai-sdk/react |
4.0.80 github npm |
@ai-sdk/replicate |
3.0.30 github npm |
@ai-sdk/revai |
3.0.29 github npm |
@ai-sdk/rsc |
3.0.77 github npm |
@ai-sdk/sandbox-just-bash |
1.0.85 github npm |
@ai-sdk/sandbox-vercel |
1.0.85 github npm |
@ai-sdk/svelte |
5.0.77 github npm |
@ai-sdk/togetherai |
3.0.36 github npm |
@ai-sdk/tui |
1.0.78 github npm |
@ai-sdk/valibot |
3.0.29 github npm |
@ai-sdk/voyage |
2.0.29 github npm |
@ai-sdk/vue |
4.0.77 github npm |
@ai-sdk/workflow |
2.0.7 github npm |
@ai-sdk/workflow-harness |
1.0.85 github npm |
@ai-sdk/xai |
4.0.43 github npm |