Skip to content

Add typed model interception - #2165

Open
xeophon wants to merge 1 commit into
agent/intercept-stream-replayfrom
agent/intercept-rewrites
Open

Add typed model interception#2165
xeophon wants to merge 1 commit into
agent/intercept-stream-replayfrom
agent/intercept-rewrites

Conversation

@xeophon

@xeophon xeophon commented Jul 29, 2026

Copy link
Copy Markdown
Member

Overview

Adds two small hooks for inspecting and changing model exchanges.

@vf.on_request receives one new vf.Messages entry before it reaches the model. @vf.on_response receives a vf.Response before it reaches the harness. A hook returns None to allow the exchange, a typed vf.Message to replace it, or vf.Terminate to end the rollout.

What this PR adds

  • @vf.on_request and @vf.on_response, with priorities and sequential replacements.
  • One request message per hook call, available as request[-1].
  • Optional Trace injection with the full branch ending at the intercepted message.
  • Trace records for replacements and termination decisions.
  • User-message handling before the harness starts.
  • Assistant response handling before the harness receives it.
  • Typed provider-native tool events for inspecting events such as Codex web search.

A request replacement must keep the same message type. A response replacement must be a text-only vf.AssistantMessage.

Stack

  1. Add interception transport and replay #2164 adds the model interception transport and buffered delivery.
  2. This PR adds the public request and response hooks.
  3. Make interception termination final #2166 makes vf.Terminate final for rollout and environment scoring.
  4. Connect harness tool interception hooks #2229 connects Bash, Claude Code, and Codex tool results to request hooks.
  5. Add interception example environments #2178 adds small example environments.

Note

Medium Risk
Changes rollout and interception-server control flow (retries, streaming, termination) and narrows intercept return types, which can break existing task interceptors.

Overview
Adds typed model interception for tasks via @vf.on_request and @vf.on_response, exported alongside InterceptRecord and Terminate.

Request hooks run on the last message before inference (including user turns via intercept_users in Rollout.step, and tool results in the interception server). Response hooks run after the model returns, before the harness sees the answer. Hooks may return a same-type replacement, Terminate, or None; decisions are recorded on the trace. Breaking: interceptors no longer accept plain str; InterceptDecision no longer carries a replacement message; intercept_response returns (decision, replacement_text).

Introduces ProviderToolEvent on AssistantMessage.provider_tools, parsed from Anthropic and OpenAI Responses dialects so provider-hosted tools (e.g. web search) are visible in traces.

The graph gains commit_prompt so a request-side Terminate can commit the conversation prefix without a model call. The interception server reorders refusal checks, in-flight coalescing, and stream idempotency, and merges request/response interception records on each turn.

Reviewed by Cursor Bugbot for commit 9485382. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add typed model interception with @on_request and @on_response task hooks

  • Adds @on_request and @on_response decorator factories so tasks can declare hooks that run before and after model inference respectively, with support for message rewriting and rollout termination.
  • Introduces ProviderToolEvent to represent provider-hosted tool activity (e.g. Anthropic/OpenAI built-in tools), now attached to AssistantMessage.provider_tools and rendered in trace output.
  • Extends the interception server to execute request hooks on incoming tool results, record InterceptRecord entries, and support pre-inference termination via PendingTurn.commit_prompt.
  • intercept_response now mutates the Response in place and returns (InterceptDecision, replacement_text | None); both request and response records are appended to trace.interceptions.
  • Risk: InterceptResult no longer accepts str; hooks must return Message, Terminate, or None, and InterceptDecision no longer carries a rewritten message directly.

Macroscope summarized 9485382.

Comment thread verifiers/v1/interception/server.py
Comment thread verifiers/v1/interception/server.py
Comment thread verifiers/v1/graph.py Outdated
Comment thread verifiers/v1/dialects/responses.py Outdated
Comment thread verifiers/v1/interception/server.py Outdated
Comment thread verifiers/v1/session.py Outdated
@macroscopeapp

macroscopeapp Bot commented Jul 29, 2026

Copy link
Copy Markdown

Approvability

Verdict: Needs human review

Unable to check for correctness in 9485382. This PR adds a new interception feature with new public API. Two high-severity bugs have been identified in review comments: tool rewrites are incorrectly rejected, and response termination references an undefined attribute. These issues require resolution before approval.

You can customize Macroscope's approvability policy. Learn more.

@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: 1811fdfbf3

ℹ️ 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 verifiers/v1/dialects/responses.py Outdated
Comment thread verifiers/v1/interception/server.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: a9826c5dc5

ℹ️ 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 verifiers/v1/interception/server.py Outdated
Comment thread verifiers/v1/session.py Outdated
@xeophon
xeophon force-pushed the agent/intercept-rewrites branch from a9826c5 to 3bec3e8 Compare July 29, 2026 16:56
Comment thread verifiers/v1/graph.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: 076bad00ca

ℹ️ 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 verifiers/v1/dialects/chat.py
@xeophon
xeophon force-pushed the agent/intercept-rewrites branch from 076bad0 to 8600d36 Compare July 29, 2026 17:10
Comment thread verifiers/v1/interception/server.py Outdated
Comment thread verifiers/v1/interception/server.py Outdated
Comment thread verifiers/v1/interception/server.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: c06a7847c3

ℹ️ 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 verifiers/v1/dialects/anthropic.py Outdated
@xeophon
xeophon force-pushed the agent/intercept-rewrites branch from c06a784 to 7c185b3 Compare July 29, 2026 17:20
Comment thread verifiers/v1/session.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: 7c185b3723

ℹ️ 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 verifiers/v1/interception/server.py Outdated
@xeophon
xeophon force-pushed the agent/intercept-rewrites branch from 7c185b3 to 02c134e Compare July 29, 2026 17:26
Comment thread verifiers/v1/dialects/anthropic.py
@xeophon
xeophon force-pushed the agent/intercept-rewrites branch from 4659dc4 to da40b40 Compare July 29, 2026 17:39

@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: 587c514b2e

ℹ️ 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 verifiers/v1/session.py Outdated
Comment thread verifiers/v1/dialects/chat.py Outdated
@xeophon
xeophon force-pushed the agent/intercept-rewrites branch from 587c514 to d9bad21 Compare July 29, 2026 18:09
Comment thread verifiers/v1/interception/server.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: d9bad21229

ℹ️ 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 verifiers/v1/dialects/chat.py
Comment thread verifiers/v1/interception/server.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: 00137f6f41

ℹ️ 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 verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.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: 93882b287d

ℹ️ 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 verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.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: 538591e8cb

ℹ️ 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 verifiers/v1/rollout.py Outdated
Comment thread verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.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: b40cbb0dfc

ℹ️ 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 verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.py Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 4, 2026

Copy link
Copy Markdown

Macroscope skipped reviewing this pull request. Per-PR cost limit exceeded (workspace setting).

Reviews on this PR have cost $99.61 so far. This review would add an estimated $2.26, bringing the total to $101.87 — above your per-PR limit of $100.00.

Tip

To get this pull request reviewed, you can:

  1. Comment @macroscope-app on this PR to request a manual review (monthly spend limits still apply).
  2. Exclude large or generated files from review by adding a pattern to your .macroscope/ignore.md — note that creating this file replaces Macroscope's built-in default ignores rather than extending them.
  3. Raise your cost limit in your workspace billing settings.

Turn off this reminder going forward

@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: 7116fc75fb

ℹ️ 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 verifiers/v1/types.py Outdated
Comment thread verifiers/v1/types.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: e56ed059f2

ℹ️ 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 verifiers/v1/interception/server.py Outdated
Comment thread verifiers/v1/intercepts/tools.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: a6a224bfd9

ℹ️ 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 verifiers/v1/types.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: 126529f58e

ℹ️ 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 verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/intercepts/tools.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: 2dbce12916

ℹ️ 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 verifiers/v1/intercepts/tools.py Outdated
Comment thread verifiers/v1/interception/server.py
Comment thread verifiers/v1/rollout.py
Comment thread verifiers/v1/session.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: 8d0e76c03c

ℹ️ 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 verifiers/v1/interception/server.py Outdated
Comment thread verifiers/v1/session.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: 0701022efb

ℹ️ 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 verifiers/v1/session.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: 6f617c247f

ℹ️ 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 verifiers/v1/session.py
Comment thread verifiers/v1/session.py
Comment thread verifiers/v1/interception/server.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: cb37d77911

ℹ️ 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 verifiers/v1/rollout.py Outdated
Comment thread verifiers/v1/session.py
Comment thread verifiers/v1/interception/server.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: 644c594eb8

ℹ️ 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 verifiers/v1/session.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: 4e2352ea0f

ℹ️ 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".

except BaseException:
abandon()
raise
if messages[-1] != original:

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 Allow tool-result rewrites to reach the model

When an @on_request hook returns a sanitized ToolMessage for a tool result, this newly added check turns the same-type rewrite into a TaskError instead of sending the redacted content to the model. The public hook contract allows replacing request[-1] with the same message type, so tool-output sanitizers either crash the rollout here or cannot be written for the server-side tool-result path; update the provider request body for the rewritten tool result or avoid dispatching rewrite-capable request hooks on ToolMessages.

Useful? React with 👍 / 👎.

TaskError(
"tool results can only be rewritten by a harness tool hook"
),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tool rewrites rejected after accept

High Severity

@on_request is documented to replace request[-1] with a same-type message, and intercept_request applies that rewrite for tool results. The interception server then fails the turn with a TaskError, so a documented tool-result replacement aborts the rollout instead of replacing the message or ending cleanly via Terminate.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4e2352e. Configure here.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 25 total unresolved issues (including 24 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9485382. Configure here.

)
stream_owner: tuple[str, asyncio.Future[StreamReplay | None]] | None = None
if stream_key is not None:
request_id, identity = stream_key

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Broken response termination path

High Severity

When an @on_response hook returns Terminate on a non-streaming turn, the server reads session.trace.terminated_by_intercept, which is not defined on Trace. That raises before commit/terminate run, so the rollout never records the interception and the failure is surfaced as a retryable 502 instead of ending the exchange.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9485382. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants