Skip to content

feat(agent): agent interruptions#2767

Open
jordan-umusu wants to merge 5 commits into
mainfrom
feat/agent-interruptions
Open

feat(agent): agent interruptions#2767
jordan-umusu wants to merge 5 commits into
mainfrom
feat/agent-interruptions

Conversation

@jordan-umusu

@jordan-umusu jordan-umusu commented May 26, 2026

Copy link
Copy Markdown
Collaborator

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

    • API: POST /workspaces/{workspace_id}/agent/sessions/{session_id}/cancel with AgentSessionCancelRequest/Response; adds AgentCancelReason (user_cancel, worker_drain) and turn_status (AgentSessionStatus) in session reads.
    • Persistence: Alembic migration adds indexed agent_session.status for turn lifecycle.
    • Orchestration/Runtime: Temporal workflow updates session status and handles cancel; executor/loopback mark runs cancelled and emit INTERRUPT; broker can interrupt active runtimes; runtime honors interrupts before/after query and during approvals; Vercel adapter emits data-interrupt and filters SDK interrupt text; router returns 409 if a session isn’t running or is busy.
    • Frontend: Stop action via useCancelChatTurn, cancel state in input, and a single interrupt notice in the timeline; client types/services updated.
  • Bug Fixes

    • Use Temporal as source of truth for active turns to avoid double-runs and clear stale running state; workflow failures now clear running state and set a final turn status.
    • Interruptions during approval finalize the turn to stopped, suppress duplicate SDK interrupt text, and display one interrupt notice.
    • Block new turns while waiting_for_approval; reject overlapping/invalid runs with 409.

Written for commit dba556b. Summary will update on new commits.

Review in cubic

image

@jordan-umusu jordan-umusu added enhancement New feature or request agents LLM agents labels May 26, 2026
@zeropath-ai

zeropath-ai Bot commented May 26, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to dba556b.

Security Overview
Detected Code Changes

The diff is too large to display a summary of code changes.

@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch from 29e4c6a to 3a19619 Compare May 27, 2026 14:39
@blacksmith-sh

This comment has been minimized.

@jordan-umusu jordan-umusu marked this pull request as ready for review May 27, 2026 14:42

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread packages/tracecat-ee/tracecat_ee/agent/workflows/durable.py

@cubic-dev-ai cubic-dev-ai 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.

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 with curr_run_id if 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 and curr_run_id are only persisted after successful initialization (or are reliably reverted on failure).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread tracecat/agent/session/activities.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/session/schemas.py
@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch 2 times, most recently from 344e5bf to 1c28e31 Compare May 27, 2026 18:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/session/service.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/executor/activity.py Outdated
@blacksmith-sh

This comment has been minimized.

@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch from 6b538c3 to 2504fbb Compare May 27, 2026 20:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/session/service.py
@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch from 2504fbb to e594570 Compare May 27, 2026 20:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/session/activities.py

@cubic-dev-ai cubic-dev-ai 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.

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

Comment thread packages/tracecat-ee/tracecat_ee/agent/workflows/durable.py
@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch from 873e4af to 611153a Compare May 27, 2026 21:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/session/service.py Outdated
@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch from 611153a to d0d353d Compare May 27, 2026 21:43

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/session/service.py Outdated
@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch from d0d353d to 4377150 Compare May 28, 2026 19:29
@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch from 4377150 to d7054ea Compare May 28, 2026 19:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/session/service.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread tracecat/agent/session/service.py Outdated
Comment on lines +638 to +641
try:
workflow_status = await self._describe_curr_run(agent_session)
except Exception:
return True

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@cubic-dev-ai cubic-dev-ai 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.

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

Comment thread tracecat/agent/session/service.py Outdated
@jordan-umusu jordan-umusu force-pushed the feat/agent-interruptions branch from 9c95128 to dba556b Compare May 28, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents LLM agents enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant