feat(ai-harness): add toolCallId to step.ask questions from a durable tool #2316 (GitHub #2315)
main fromrefs/pull/2315/head·opened View on GitHubA step.ask question inside a durable tool call now carries that call's toolCallId, in ViewQuestion, snapshot().pendingWaits, and onQuestion. Approvals, client tools, and interrupts already have this field. Questions from commands and agent runs are unchanged.
🎯 Changes#
When a durable tool calls step.ask, the session knows which tool call asked: the wait id is ask:<toolCallId>:<name>. The view does not carry it: ViewQuestion has no toolCallId, while Approval, ViewInterrupt, and ClientToolCall all have one. A UI that shows a question next to the tool call that asked it has to rebuild the wait id from the internal ask:<scope>:<name> format. We hit this in an app where a choice tool shows its options as buttons on the tool call that asked.
stepAskstores the tool call id on the wait record when the steps belong to a durable tool call. The id then flows toPendingWait,PendingQuestion(and so theharness.questionevent), andViewQuestion.- Commands and agent runs use the same step binding, but their scope is a command or run key, not a tool call, so their questions have no
toolCallId. Astep.askin an agent tool becomes a turn interrupt, so it shows in the view'sinterrupts, notquestions. It is unchanged. - Docs: the field is listed in "Show a question" (
custom-ui.md) and in thependingWaitsnotes (waits.md).
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I fully understand the code in this pull request, including any code generated with AI assistance.
- Docs: I updated
docs/for this change, or this change is not user-facing. - Changeset: I added a changeset (
pnpm changeset), or this PR does not change a published package.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Test plan#
packages/ai-harness/tests/step-ask.test.ts, "gives the question in a view the id of the tool call that asks": a durable tool callcall-1asks a question, and the session view'squestions[0]is{ id: 'ask:call-1:name', toolCallId: 'call-1' }. The existing durable-tool case now also expectstoolCallIdon the pending wait, and the command case expects none.- Without the source change, the new test and the existing durable-tool case fail (2 failed, 10 passed). With it, all 12 pass.
pnpm test:prpasses locally on Node 24.22.1 and pnpm 11.9.0. Itstest:dtsstep is clean too.- The change adds an optional
toolCallIdfield and is covered by unit tests, so there is no new E2E test.
Summary by CodeRabbit#
- New Features
- Questions asked by durable tools now include the ID of the tool call that asked them, visible in session views, pending waits, and question events.
- Documentation
- Updated question and wait documentation to describe the optional tool call ID.
- 1
No actionable comments were generated in the recent review.
Walkthrough
-
Durable-tool
step.askquestions now carry the asking call’stoolCallIdin wait records and question events. Pending waits and session-view questions expose the ID when present. Tests and documentation cover the new field and command waits without it.Changes: Durable tool question call IDs
Layer / File(s) Summary Capture toolCallId when durable tools ask
packages/ai-harness/src/types.ts,packages/ai-harness/src/log-records.ts,packages/ai-harness/src/session/turn-parts.ts,packages/ai-harness/src/session/agents.tsDurable tool bindings identify their calls when they invoke stepAsk. When supplied,stepAskaddstoolCallIdto the question wait record and published event.Expose and verify toolCallId
packages/ai-harness/src/waits.ts,packages/ai-harness/src/view/*,packages/ai-harness/tests/step-ask.test.ts,docs/harness/*,.changeset/step-ask-tool-call-id.mdPending waits and session-view questions include toolCallIdwhen present. Tests check durable-tool questions and confirm command waits omit the field. Documentation and the changeset describe the addition.Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Feature
Sequence Diagram(s)#
sequenceDiagram participant durableBinder participant durableBinding participant stepAsk participant WaitRecord participant onQuestion participant snapshotWaits participant SessionView durableBinder->>durableBinding: Mark binding as a tool call durableBinding->>stepAsk: Pass toolCallId when asking stepAsk->>WaitRecord: Store question with toolCallId stepAsk->>onQuestion: Publish question with toolCallId WaitRecord->>snapshotWaits: Include toolCallId in pending wait onQuestion->>SessionView: Include toolCallId in questionSuggested reviewers:
alemtuzlak,jherr
Merge Risk:
Minimal · up toe63cb-
This adds an optional tool call ID to questions asked by durable tools, so a UI can link a question to the tool call that asked it. Existing questions and commands are unchanged. No merge-blocking risk was found.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: an optional toolCallId is added to step.ask questions asked from a durable tool. The changeset, types, view, waits, and tests all implement this. The title follows the… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Description check The description explains the change: step.ask questions in durable tool calls now carry the tool call's toolCallId through the wait record, PendingWait, PendingQuestion, the harness.question event, Vi… Full details: Title check
-
Explanation
The title names the main change: an optional toolCallId is added to step.ask questions asked from a durable tool. The changeset, types, view, waits, and tests all implement this. The title follows the conventional commit format and is specific to the primary change.
Full details: Description check
-
Explanation
The description explains the change: step.ask questions in durable tool calls now carry the tool call's toolCallId through the wait record, PendingWait, PendingQuestion, the harness.question event, ViewQuestion, and snapshot().pendingWaits. It states the motivation, scope limits (commands and agent runs unchanged, agent-tool asks become turn interrupts), and docs updates. It includes a test plan with concrete validation results. All template sections are present: Changes, the checklist, and Release Impact. The checklist items are checked, and the changeset and docs are listed as done. The Release Impact section marks a changeset as generated, which matches the changeset file in the summary. The description is complete and specific.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: TanStack/ai
- Branch: main
- File: .coderabbit.yaml
- Commit: 1c55fd5
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f2ab6fbb-225e-4aca-bddf-5681b95efe9d
Commits-
Reviewing files that changed from the base of the PR and between 1c55fd51d2fcafb84f59295736bc42f6d2353868 and e63cb19955d3c2ecd8e4da13864b0f09e82b5875.
Files selected for processing: 12-
.changeset/step-ask-tool-call-id.mddocs/harness/custom-ui.mddocs/harness/waits.mdpackages/ai-harness/src/log-records.tspackages/ai-harness/src/session/agents.tspackages/ai-harness/src/session/turn-parts.tspackages/ai-harness/src/types.tspackages/ai-harness/src/view/index.tspackages/ai-harness/src/view/reduce.tspackages/ai-harness/src/view/types.tspackages/ai-harness/src/waits.tspackages/ai-harness/tests/step-ask.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
-
-
tanstack-source added labelsfeature
github-actions[bot](GitHub profile, opens in a new tab) assignedAlemTuzlak
Thanks for the PR, @381181295! 🙌 @AlemTuzlak will take a look.
Automated pre-review checks
- ✅ CI passing
- ✅ No merge conflicts
- ✅ Changeset present
- ⚠️ No E2E test changes detected — behavior changes need coverage under
testing/e2e/(see CONTRIBUTING)
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: e63cb19955d3c2ecd8e4da13864b0f09e82b5875
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR