Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-harness): add toolCallId to step.ask questions from a durable tool #2316 (GitHub #2315)

Open381181295(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2315/headopened View on GitHub

381181295(GitHub profile, opens in a new tab)commented

A 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.

  • stepAsk stores the tool call id on the wait record when the steps belong to a durable tool call. The id then flows to PendingWait, PendingQuestion (and so the harness.question event), and ViewQuestion.
  • 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. A step.ask in an agent tool becomes a turn interrupt, so it shows in the view's interrupts, not questions. It is unchanged.
  • Docs: the field is listed in "Show a question" (custom-ui.md) and in the pendingWaits notes (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 call call-1 asks a question, and the session view's questions[0] is { id: 'ask:call-1:name', toolCallId: 'call-1' }. The existing durable-tool case now also expects toolCallId on 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:pr passes locally on Node 24.22.1 and pnpm 11.9.0. Its test:dts step is clean too.
  • The change adds an optional toolCallId field 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. 🦋 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
      NameType
      @tanstack/ai-harnessMinor
      @tanstack/ai-acpPatch
      @tanstack/ai-code-modePatch
      @tanstack/ai-computer-usePatch
      @tanstack/ai-harness-cliPatch
      @tanstack/ai-mcpPatch
      @tanstack/ai-sandboxPatch
      @tanstack/ai-skillsPatch
      @tanstack/ai-optimize-evalsPatch

      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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      Durable-tool step.ask questions now carry the asking call’s toolCallId in 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.ts
      Durable tool bindings identify their calls when they invoke stepAsk. When supplied, stepAsk adds toolCallId to 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.md
      Pending waits and session-view questions include toolCallId when 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 question

      Suggested reviewers: alemtuzlak, jherr

      Merge Risk: Minimal · up to e63cb

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Description checkPassedThe 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.

      Share

      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.md
      • docs/harness/custom-ui.md
      • docs/harness/waits.md
      • packages/ai-harness/src/log-records.ts
      • packages/ai-harness/src/session/agents.ts
      • packages/ai-harness/src/session/turn-parts.ts
      • packages/ai-harness/src/types.ts
      • packages/ai-harness/src/view/index.ts
      • packages/ai-harness/src/view/reduce.ts
      • packages/ai-harness/src/view/types.ts
      • packages/ai-harness/src/waits.ts
      • packages/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.

    3. tanstack-source added labelsfeature

    4. 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)
      Automated triage — a human review follows.
    5. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

Sign in to join this conversation.