Skip to content

[Bug] openai-agents (TypeScript): stream topic subscribers get the rest of the answer after a parallel input guardrail trips #428

Open

Description

@campoy

On the experimental streaming route (new TemporalOpenAIRunner().run(agent, input, { stream: true }) with modelParams.streamingTopic), an input guardrail in the default parallel mode (runInParallel: true) can trip while the model is still streaming. The Workflow's own stream loop then gets InputGuardrailTripwireTriggered, as it does natively. But subscribers of the stream topic get the rest of the answer and response_done, with no sign that the request was rejected. A UI on the topic shows the whole answer to a rejected request.

This is the TypeScript side of #227, which #228 fixes for Python.

Why

invokeModelStreamActivity publishes each model event to the topic as the model yields it (activities.ts). In the Workflow, ActivityBackedModel.getStreamedResponse awaits the whole Activity and only then yields its events (activity-backed-model.ts). @openai/agents-core checks parallel input guardrails against the events it yields, so the check runs only after everything has been published, and nothing cancels the Activity when the guardrail trips.

What we saw

A parallel input guardrail awaited a policy Activity and a 1 s timer, then tripped. A fake model sent five deltas 300 ms apart, then response_done.

  • Natively (Runner from @openai/agents-core), the consumer got three deltas, then InputGuardrailTripwireTriggered.
  • Through the plugin, the topic subscriber got all five deltas and response_done. History has the publish Signals for the last two deltas and response_done at 1311, 1619 and 1896 ms, after the guardrail's timer fired at 1090 ms. The Workflow's own loop got no model events, then the tripwire.
  • Control: with a guardrail that allows, the native consumer, the Workflow's loop and the subscriber all got five deltas and response_done.

That run used @temporalio/openai-agents 1.24.0 (when the plugin lived in sdk-typescript, at 7ae5c7f), @temporalio/workflow-streams 1.24.0 and @openai/agents-core 0.14.3, with Temporal CLI 1.9.1. It was not rerun on this repo's main, but the code linked above is the same path.

Expected: once the guardrail trips, subscribers stop getting the answer and get a sign that it ended, as a native consumer does.

Workaround: set runInParallel: false on input guardrails for streamed runs. Then the model is not called and nothing is published.

Activity

  1. added
    bug
    on Nov 5, 2026
  2. rahulsjha commented on Nov 17, 2026

    @rahulsjha

    Hi @campoy, I'd like to pick this up. Plan: port the #228 approach to TypeScript so that when a parallel input guardrail trips, the workflow cancels the invokeModelStreamActivity in typescript/openai-agents/src/worker/activities.ts and the activity stops publishing further events to the streaming topic. Tests would trip a guardrail mid-stream and assert no model events reach subscribers after the tripwire. Since the cancel only lands if the activity heartbeats, should this wait for #491's default heartbeat timeout, or should I set one on the streaming activity as part of this change? Could you assign it to me?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions