Repository navigation
fix(api): move the last stop callers to the cancel route and deprecate the stream stop mode - #7835
Conversation
…e the stream stop mode
The /w tab close and the channel !stop command stopped a turn through the
stop mode of POST /sessions/streams/. They now send the durable cancel that
POST /sessions/{session_id}/cancel sends. The unused web helpers
cancelSessionStream and commandSessionStream are removed. The API reference
marks the stop mode deprecated, and the route logs each call to it so the
remaining callers can be counted before the mode is removed.
…used command schema
📘 Docs preview
Pages changed in this pull request This comment updates in place on every push. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Channel stop dispatch and service wiring api/oss/src/core/channels/commands.py, api/oss/src/tasks/asyncio/channels/inbox.py, api/entrypoints/routers.py, api/entrypoints/worker_queues.py, api/oss/tests/pytest/integration/channels/*, api/oss/tests/pytest/unit/channels/*, api/oss/tests/pytest/unit/sessions/test_insert_paths_require_access.py |
Channel !stop calls SessionCommandsService.request_cancel with project, user, and session IDs. Startup configures the service with the direct control-delivery adapter and passes it to InboxDispatcher. Related tests use the commands service; the ownerless-policy channel test is removed. |
Web client cancellation API web/oss/src/components/AgentChatSlice/AgentChatPanel.tsx, web/packages/agenta-entities/src/session/api/api.ts, web/packages/agenta-entities/src/session/core/schema.ts, web/packages/agenta-entities/src/session/index.ts, web/packages/agenta-entities/tests/unit/session-cancel-stream.test.ts |
The chat panel calls cancelSessionExecution when its existing close-time condition is met. The stream-command and stream-cancellation APIs, response schema and exports, and cancellation API test suite are removed. |
Deprecated stream stop mode documentation and logging api/oss/src/apis/fastapi/sessions/router.py, docs/docs/reference/api/set-session-stream.api.mdx, api/oss/tests/pytest/acceptance/sharing/test_private_session_probe.py, api/oss/tests/pytest/unit/sessions/test_cancel_cancels_pending_interactions.py |
The endpoint and API documentation describe the deprecated stop condition and direct callers to the cancel endpoint. The route logs project and session IDs when the derived command mode is cancel. Related test comments identify the deprecated mode. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Sequence Diagram(s)
sequenceDiagram
participant InboxDispatcher
participant dispatch_command
participant SessionCommandsService
InboxDispatcher->>dispatch_command: Dispatch channel command
dispatch_command->>SessionCommandsService: request_cancel(project_id, user_id, session_id)
Possibly related issues
- Agenta-AI/agenta issue 7131: The PR changes the channel
!stopcancellation call, but does not change inbox deduplication or add an idempotency key. - Agenta-AI/agenta issue 7760: The PR moves channel and web stop callers to cancellation APIs, but does not change runner-side delivery for unscoped runs.
Merge Risk: 
Minimal · up to 668b4
-
Legacy stream stop remains available, and built-in channels do not offer !stop. No merge-blocking issue was identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title names the main change: the last stop callers move to the cancel route, and the stream stop mode is deprecated. The raw summary confirms the channel !stop path, the web helper removal, and the OpenAPI deprecation note. The title uses the 'fix(api)' prefix, which fits a deprecation-and-reroute change, and it is 91 characters, slightly long but still specific.
Full details: Description check
-
Explanation
The description states the problem, the change, and the scope. It covers the /w tab close and channel !stop callers, the removed web helpers, the deprecation notes, the logging, the tests run, and the known gaps. The description is detailed and clearly related to the changeset.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 9 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- 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.
Comment @coderabbitai help to get the list of available commands.
Website previewPreview URL: https://pr-7835-agenta-website-preview.mahmoud-637.workers.dev Built from |
There was a problem hiding this comment.
🧹 Nitpick comments: 1
web/oss/src/components/AgentChatSlice/AgentChatPanel.tsx: 1
123-123:Trivial · Data Integrity & Integration · Quick win Bind close-time cancellation to the observed execution.
When enabled, this call sends neither
expectedExecutionIdnoridempotencyKey. The endpoint then resolves the current eligible execution. A delayed close request can cancel a later execution that started before the request arrives. Pass the session's tracked execution ID and a stable key for close retries, or keep this path disabled until those values are available.

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Agenta-AI/agenta
- Branch: fix/deprecate-stream-stop-mode
- File: .coderabbit.yaml
- Commit: 4957b15
- Layers: Repository YAML (base), Organization UI (inherited)
- Review profile: CHILL
- Plan: Advanced
- Run ID:
698263db-9b76-4c04-9ca9-872cfd24300d
Files selected for processing: 16-
api/entrypoints/routers.pyapi/entrypoints/worker_queues.pyapi/oss/src/apis/fastapi/sessions/router.pyapi/oss/src/core/channels/commands.pyapi/oss/src/tasks/asyncio/channels/inbox.pyapi/oss/tests/pytest/acceptance/sharing/test_private_session_probe.pyapi/oss/tests/pytest/integration/channels/test_channels_composition_seam.pyapi/oss/tests/pytest/unit/channels/test_channels_commands.pyapi/oss/tests/pytest/unit/sessions/test_cancel_cancels_pending_interactions.pyapi/oss/tests/pytest/unit/sessions/test_insert_paths_require_access.pydocs/docs/reference/api/set-session-stream.api.mdxweb/oss/src/components/AgentChatSlice/AgentChatPanel.tsxweb/packages/agenta-entities/src/session/api/api.tsweb/packages/agenta-entities/src/session/core/schema.tsweb/packages/agenta-entities/src/session/index.tsweb/packages/agenta-entities/tests/unit/session-cancel-stream.test.ts
Files with no reviewable changes: 4-
- web/packages/agenta-entities/tests/unit/session-cancel-stream.test.ts
- web/packages/agenta-entities/src/session/core/schema.ts
- web/packages/agenta-entities/src/session/index.ts
- web/packages/agenta-entities/src/session/api/api.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
-
Railway Preview Environment
PR closed or converted to draft. Environment absence verified; retained storage requires separate provider accounting. Post |
|
🤖 The AI agent says: About the CodeRabbit nitpick on |
Do not merge into main. This PR waits for the next release branch.
Problem
There are two ways to stop an agent turn.
POST /sessions/{session_id}/cancelqueues a durable stop, and the runner keeps the partial answer. The older stop mode ofPOST /sessions/streams/(a call with no inputs and noforce) clears the running owner at once. Since v0.124.0 that made the runner drop the partial answer. #7827 made the old path safe, and we agreed to retire it after external callers get notice.Our own code still called the old stop mode in two places: the /w tab close and the channel
!stopcommand. The web package also kept two helpers that used it.Change
cancelSessionExecution. This path is still switched off (CLOSE_CANCELS_RUN = false), so nothing changes for users today.!stopcommand now callsSessionCommandsService.request_cancel, the same service the cancel route uses. Both channel dispatchers (API and worker) get the commands service. No channel offers!stoptoday, so this is also dormant.cancelSessionStreamandcommandSessionStream, their response schema, and their test.set_session_streamroute now has an OpenAPI description that marks the stop mode deprecated. The API reference page carries the same note. Send, steer and attach are not deprecated.The stop mode itself stays. We remove it one or two releases later.
Closing the /w browser tab does not stop a turn
On staging (v0.125.2), closing the /w browser tab during an answer did not stop the turn. This is expected, and this PR does not change it:
AgentChatPanel.tsxruns when a user closes a session tab inside the chat, not the browser tab.CLOSE_CANCELS_RUN = falseincloseSessionCancel.ts). This PR only changes which route it would call if someone turns it on.Tests
request_cancel.test_cancel_cancels_pending_interactions.pyand the "stream cancel" probe row, because the old route is still public. Both have a note to delete them with the mode.@agenta/entitiesunit tests, and the@agenta/entitiesandweb/osstype checks. All pass.Before anyone turns on
!stopor the tab-close cancelThese gaps existed before this PR: