Skip to content

[Agent] Add support for speech streaming / interruption#1984

Open
Guikingone wants to merge 1 commit into
symfony:mainfrom
Guikingone:agent/agent_interruption
Open

[Agent] Add support for speech streaming / interruption#1984
Guikingone wants to merge 1 commit into
symfony:mainfrom
Guikingone:agent/agent_interruption

Conversation

@Guikingone

@Guikingone Guikingone commented Apr 22, 2026

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
Docs? yes
Issues Split of #1990
License MIT

@Guikingone Guikingone force-pushed the agent/agent_interruption branch from ed68d91 to 14e9d9c Compare April 23, 2026 08:50
@Guikingone Guikingone force-pushed the agent/agent_interruption branch 4 times, most recently from 485782d to 3009ef7 Compare May 22, 2026 17:33
@Guikingone Guikingone marked this pull request as ready for review May 22, 2026 17:33
@carsonbot carsonbot added Agent Issues & PRs about the AI Agent component Feature New feature Status: Needs Review labels May 22, 2026
Adds InterruptionSignal/InterruptionSignalInterface and integrates
cooperative checks at phase boundaries in Agent, MultiAgent, SpeechAgent
via the new InterruptibleTrait. Introduces SpeechSession to manage
signals and cancel previous in-flight results across successive calls.
Makes Chat transactional (cloned MessageBag) so interruptions don't
pollute the store.

For streaming TTS, SpeechAgent attaches an InterruptionStreamListener
to the returned StreamResult so the signal is observed between deltas
too, not only at coarse phase boundaries. SpeechConfiguration grows a
`ttsStream` flag (and `shouldStreamTextToSpeech()` accessor) that
propagates `stream: true` to the TTS bridge.

Pulls in the cancellation primitives the feature relies on:
CancellableInterface, StreamResult::cancel()/isCancelled() honouring
the cancelled flag inside the generator loop and Event::stop()
requests, and RawHttpResult::cancel() forwarding to the underlying
ResponseInterface::cancel(). DeferredResult implements
CancellableInterface and cascades cancellation to raw and converted
results, throwing CancelledResultException on access after cancel.

ai-bundle exposes the SpeechSession decorator via `speech.session: true`
on agent configuration.

Drive-by: refactor the Schema enum-guard to use foreach + gettype()
instead of a chained is_int/is_float/is_string closure, removing the
stale `@phpstan-ignore` directive that PHPStan 2.x no longer matched.
@Guikingone Guikingone force-pushed the agent/agent_interruption branch from 3009ef7 to 175c076 Compare June 8, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Agent Issues & PRs about the AI Agent component Feature New feature Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants