Skip to content

fix(agents): resume queued turns after questionnaire answers - #6603

Merged
mmabrouk merged 4 commits into
release/v0.115.2from
fix/release-1152-questionnaire-resume
Sep 6, 2026
Merged

fix(agents): resume queued turns after questionnaire answers#6603
mmabrouk merged 4 commits into
release/v0.115.2from
fix/release-1152-questionnaire-resume

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Sep 6, 2026

Copy link
Copy Markdown
Member

Context

Submitting a questionnaire from a queued agent turn saved the answer but left the run stuck. The browser then tried to resume the runner directly; the server correctly refused because the queued continuation still owned the session. The UI showed “A saved approval is resuming,” and later messages remained queued. This was reproduced with two local browser tabs.

Changes

Desktop and mobile now submit client-tool answers through the existing server-owned response path when durable approvals are enabled. The answer keeps its structured values and a stable retry identity, and the returned execution ID holds the queue until continuation finishes. Servers without that capability keep the existing ordered local resume.

The dispatcher reconstructs client-tool history and the answered tool result before invoking the continuation, preserving successful output and error results. Native approvals and generic user-input pass-through keep their existing behavior. A failed questionnaire submission appears in the form’s existing error line and can be retried without starting a competing local resume. Connection answers likewise preserve rejected submission promises and retry the saved answer without creating another connection.

Tests

The real two-tab failure and a focused shared-hook regression failed before the fix. Afterward, 30 dispatcher tests, 64 shared hook/form/ownership tests, 14 desktop hook tests five entity/API tests and 12 connection tests pass. Shared chat, entity and entity-UI TypeScript checks and full frontend lint-fix pass (25 tasks).

Demo

The corrected dispatcher also resumed the previously stuck local questionnaire through the canonical response endpoint: one continuation finished with the selected answer and the queue cleared. The baked questionnaire frontend passed local two-tab and mobile checks: the second tab submitted Visual polish with the untouched Daily default, one continuation completed, both tabs settled, and the next message completed. Mobile submitted Yes through one durable response and returned to idle. Saved records confirm one exact answer and one terminal for each run; screenshots were visually inspected. These images match the questionnaire implementation; the later connection-retry-only correction has focused regression, type and lint coverage. The exact final source also passed staging: a questionnaire queued behind a running turn was answered on mobile through one durable response, its exact answer and terminal were saved, and a normal follow-up completed with an empty queue. A separate first-send capability initialization finding is retained for follow-up, outside this fix. The original reproduction and final captures are retained in private QA evidence.

What to QA

While one turn runs, queue a questionnaire request. Answer it from a second tab, keeping one default value unchanged. Confirm one continuation receives the exact answers, both tabs settle, and the next queued message completes. Repeat one questionnaire submission on mobile.

@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
agenta-documentation Ready Ready Preview Sep 6, 2026 1:13pm UTC

Request Review

@mmabrouk

mmabrouk commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

@coderabbitai review

Please review the client-tool answer ownership and dispatcher reconstruction, including rejection retries and the legacy capability fallback. Independent source review and focused regressions passed. Exact-image local two-client and mobile validation will follow the CI builds; this PR is not ready to merge until that proof and your completed review are available.

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 652b9c81-46fb-48e8-9a00-04969d8003d1

📥 Commits

Reviewing files that changed from the base of the PR and between 0cd481f and a2e2d81.

📒 Files selected for processing (4)
  • web/packages/agenta-chat/src/components/ConnectionDock.tsx
  • web/packages/agenta-entities/tests/unit/session-interaction-answer.test.ts
  • web/packages/agenta-entity-ui/src/clientTools/useConnectFlow.ts
  • web/packages/agenta-entity-ui/tests/unit/useConnectFlow.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • web/packages/agenta-entities/tests/unit/session-interaction-answer.test.ts
  • web/packages/agenta-entity-ui/src/clientTools/useConnectFlow.ts
  • web/packages/agenta-entity-ui/tests/unit/useConnectFlow.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Client-tool and questionnaire answers now support durable submission and continuation handling.
    • Answer submissions can complete asynchronously before the conversation resumes.
    • Failed submissions remain retryable and display a clear error message.
  • Bug Fixes

    • Completed and failed client-tool results are correctly replayed in resumed conversations.
    • Error details and status are preserved when returning tool results.
    • Improved handling of connected-tool and elicitation submission failures.

Walkthrough

Client-tool outputs now use durable interaction answers when supported, with legacy fallback handling. The backend replays completed and error outcomes as tool_result messages. Client-tool and connection UI flows now propagate asynchronous settlement failures and support retries.

Changes

Client-tool answer flow

Layer / File(s) Summary
Client-tool result replay
api/oss/src/tasks/asyncio/sessions/interactions_dispatcher.py, api/oss/tests/pytest/unit/sessions/test_interactions_dispatcher.py
The dispatcher recognizes completed and error client-tool answers and replays them as tool_result messages. Tests cover both outcomes.
Durable answer contract and submission
web/packages/agenta-entities/src/session/state/interactionAnswer.ts, web/packages/agenta-chat/src/hooks/useAgentConversation.ts, web/packages/agenta-chat/src/clientTools/ClientToolPart.tsx, web/packages/agenta-shared/src/clientTools/index.ts, related tests
Structured client-tool resolutions use client-tool idempotency keys and durable submission. Settlement handlers now return asynchronous results.
OSS session wiring and ownership
web/oss/src/components/AgentChatSlice/AgentConversation.tsx, web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts, related tests
The OSS session routes client-tool answers through durable capability handling and updates continuation state for the active response owner.
Retryable settlement errors
web/packages/agenta-chat/src/components/ElicitationDock.tsx, web/packages/agenta-chat/src/components/ConnectionDock.tsx, web/packages/agenta-entity-ui/src/clientTools/useConnectFlow.ts, related tests
Settlement failures reset settled state, display error text, preserve pending answers, and allow retries without recreating connections.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to a2e2d

Connection-answer submission failures now clearly present a Retry action, avoiding the prior misleading Connect label. No active merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant ClientToolUI
  participant AgentConversation
  participant InteractionAnswerAtom
  participant SessionAPI
  participant InteractionDispatcher
  ClientToolUI->>AgentConversation: submit output or error
  AgentConversation->>InteractionAnswerAtom: send structured resolution
  InteractionAnswerAtom->>SessionAPI: respond with idempotency key
  SessionAPI-->>AgentConversation: return execution outcome
  SessionAPI->>InteractionDispatcher: provide completed or error answer
  InteractionDispatcher-->>ClientToolUI: replay tool_result message
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 16 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description directly explains the queued-turn questionnaire bug, the server-owned response fix, retry behavior, dispatcher changes, and related tests.
Title check ✅ Passed The title clearly summarizes the primary change: resuming queued turns after questionnaire answers.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/release-1152-questionnaire-resume

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/agenta-chat/src/components/ConnectionDock.tsx (1)

576-576: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Label the retry state correctly. When useConnectFlow sets errorText after submission failure, Line 576 renders “Connect” instead of “Retry”.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: c47900b2-96c7-41fe-8cad-322659a430d3

📥 Commits

Reviewing files that changed from the base of the PR and between 9f090e8 and 0cd481f.

📒 Files selected for processing (16)
  • api/oss/src/tasks/asyncio/sessions/interactions_dispatcher.py
  • api/oss/tests/pytest/unit/sessions/test_interactions_dispatcher.py
  • web/oss/src/components/AgentChatSlice/AgentConversation.tsx
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.test.ts
  • web/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.ts
  • web/packages/agenta-chat/src/clientTools/ClientToolPart.tsx
  • web/packages/agenta-chat/src/components/ConnectionDock.tsx
  • web/packages/agenta-chat/src/components/ElicitationDock.tsx
  • web/packages/agenta-chat/src/hooks/useAgentConversation.ts
  • web/packages/agenta-chat/tests/unit/components/elicitationDockSettle.test.tsx
  • web/packages/agenta-chat/tests/unit/hooks/useAgentConversation.test.ts
  • web/packages/agenta-entities/src/session/state/interactionAnswer.ts
  • web/packages/agenta-entities/tests/unit/session-interaction-answer.test.ts
  • web/packages/agenta-entity-ui/src/clientTools/useConnectFlow.ts
  • web/packages/agenta-entity-ui/tests/unit/useConnectFlow.test.ts
  • web/packages/agenta-shared/src/clientTools/index.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

it("preserves questionnaire content and stable retry identity without legacy transition", async () => {
const store = createStore()
store.set(projectIdAtom, "project-id")
store.set(queryClientAtom, new QueryClient())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the shared test QueryClient setup. Line 47 constructs new QueryClient() despite the project rule that forbids local QueryClient construction. As per coding guidelines, “Never construct your own new QueryClient().”

Source: Coding guidelines

Comment thread web/packages/agenta-entity-ui/src/clientTools/useConnectFlow.ts Outdated
Comment thread web/packages/agenta-entity-ui/src/clientTools/useConnectFlow.ts
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review pull request #6603 with focus on the requested flows. I will treat the pending two-client and mobile CI-image validation as a merge-blocking requirement.

⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-09-06T13:31:45.692Z

@mmabrouk

mmabrouk commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

Addressed review findings in a2e2d81:

  • 3944020718: retain the unsaved connection answer and retry its submission before creating a connection. The regression failed with two creates before the fix and now verifies one create, identical answer retry, and refusal controls preserving that answer.
  • 3944020711: shortened the new comment.
  • Outside-diff Retry label: the dock now labels the submission failure action Retry and disables Not now until that answer is settled.
  • 3944020708: retained an isolated QueryClient in this unit fixture intentionally. This test supplies a fresh Jotai store and mocked API calls, consistent with neighboring session-file-activity and session-mounts-store tests. Importing the application singleton would share cache state across tests; the application-level no-new-client rule prevents duplicate runtime providers rather than independent test clients.

Also corrected the two CI formatting findings. Focused connection tests, chat/entity-ui types and full frontend lint pass. Independent review of this follow-up passed. The original questionnaire images are now running locally; the connection retry delta has separate regression coverage and new CI builds.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review the follow-up changes. I will verify the connection-answer retry path, refusal controls, durable and legacy capability paths, and regression coverage.

⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mmabrouk
mmabrouk merged commit 73d7227 into release/v0.115.2 Sep 6, 2026
68 of 71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant