feat(agent): agent interruptions#2767
Conversation
|
✅ No security or compliance issues detected. Reviewed everything up to dba556b. Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. |
29e4c6a to
3a19619
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a19619bbc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
1 issue found
Confidence score: 3/5
- There is a concrete regression risk in
tracecat/agent/session/activities.py: setting the session to RUNNING before setup completes can leave stale RUNNING state withcurr_run_idif initialization later fails. - Because this is severity 7/10 with high confidence (8/10) and can cause user-visible session state inconsistency, the PR carries some merge risk until ordering/rollback is handled.
- Pay close attention to
tracecat/agent/session/activities.py- ensure session status andcurr_run_idare only persisted after successful initialization (or are reliably reverted on failure).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e07acafb28
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
344e5bf to
1c28e31
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c28e31a1b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b538c3cb9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This comment has been minimized.
This comment has been minimized.
6b538c3 to
2504fbb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2504fbbd37
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
2504fbb to
e594570
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 873e4af7c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
873e4af to
611153a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 611153a1c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
611153a to
d0d353d
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0d353d8b8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
d0d353d to
4377150
Compare
4377150 to
d7054ea
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7054ea003
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c951289ac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try: | ||
| workflow_status = await self._describe_curr_run(agent_session) | ||
| except Exception: | ||
| return True |
There was a problem hiding this comment.
Clear stale run ids when Temporal no longer has the run
For sessions that already have a curr_run_id from an older completed turn, once the corresponding Temporal execution is no longer describable (for example after retention, or a deleted namespace/history), this broad except makes _has_active_agent_turn() return True forever. That causes validate_turn_request() to reject every new message for the chat even though there is no active workflow left to overlap; handle the workflow-not-found/stale-run case by clearing curr_run_id and projecting a terminal/idle status instead of treating it as active.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
9c95128 to
dba556b
Compare

Summary by cubic
Adds graceful interruption for running agent turns with end-to-end turn status. Users can stop a run from the UI, see a single interrupt notice (including during approval), and the backend now uses Temporal state to prevent stuck or overlapping runs.
New Features
POST /workspaces/{workspace_id}/agent/sessions/{session_id}/cancelwithAgentSessionCancelRequest/Response; addsAgentCancelReason(user_cancel,worker_drain) andturn_status(AgentSessionStatus) in session reads.agent_session.statusfor turn lifecycle.INTERRUPT; broker can interrupt active runtimes; runtime honors interrupts before/after query and during approvals; Vercel adapter emitsdata-interruptand filters SDK interrupt text; router returns 409 if a session isn’t running or is busy.useCancelChatTurn, cancel state in input, and a single interrupt notice in the timeline; client types/services updated.Bug Fixes
stopped, suppress duplicate SDK interrupt text, and display one interrupt notice.waiting_for_approval; reject overlapping/invalid runs with 409.Written for commit dba556b. Summary will update on new commits.
Review in cubic