Skip to content

fix(voice): support context in single-agent workflow - #4636

Merged
seratch merged 2 commits into
openai:mainfrom
sylvesterkaczmarek:feat/single-agent-voice-context-4635
Aug 25, 2026
Merged

fix(voice): support context in single-agent workflow#4636
seratch merged 2 commits into
openai:mainfrom
sylvesterkaczmarek:feat/single-agent-voice-context-4635

Conversation

@sylvesterkaczmarek

@sylvesterkaczmarek sylvesterkaczmarek commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This pull request adds first-class Runner context support to SingleAgentVoiceWorkflow.

SingleAgentVoiceWorkflow now accepts an optional keyword-only context argument and forwards the same application context to each internal Runner.run_streamed() call. This lets the convenience voice workflow use context-dependent instructions, tools, handoffs, and enablement predicates without requiring users to copy the workflow into a custom VoiceWorkflowBase implementation.

The existing positional constructor contract is preserved: agent remains first and callbacks remains second. Custom workflows remain the supported path for broader per-turn Runner customization.

Following review, the constructor now preserves the SDK's existing context type relationship by using agent: Agent[TContext] and context: TContext | None rather than erasing both to Any.

Test plan

  • uv run pytest -q tests/voice/test_workflow.py — passed on the pre-review implementation
  • Changed-file Ruff formatting and lint — passed on the pre-review implementation
  • Focused mypy for src/agents/voice/workflow.py — passed on the pre-review implementation
  • Fork CI lint — passed on the pre-review implementation
  • Prospective release API contract — passed on the pre-review implementation
  • Windows mypy — passed on the pre-review implementation
  • The latest typing-only review-fix commit triggered GitHub Actions, but the fork workflow is currently action_required and has not started jobs yet; it requires maintainer approval before the updated checks can run.

The regression test executes a real context-aware function tool on two separate voice turns and verifies that the same context reaches both invocations.

Issue number

Closes #4635

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution. The placement and lifetime look right: SingleAgentVoiceWorkflow owns the Runner invocation and conversation history, so storing one application context on the workflow and forwarding it to every turn is the narrowest coherent design.

Before merging, please update the constructor typing so the agent and context share TContext: use agent: Agent[TContext] and context: TContext | None, following Runner.run_streamed(), instead of erasing both to Any. This lets type checkers catch mismatched agent/context pairs and preserves the SDK's existing context contract. The implementation can continue forwarding the raw application object; no voice-specific wrapper or broader VoicePipeline API is needed. The existing two-turn tool test is sufficient for runtime forwarding.

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

Updated the constructor typing as requested so the agent and context share TContext, while leaving the runtime forwarding behaviour unchanged.

@seratch seratch changed the title feat(voice): support context in single-agent workflow fix(voice): support context in single-agent workflow Aug 25, 2026
@seratch
seratch enabled auto-merge (squash) August 25, 2026 00:07
@seratch seratch added this to the 0.22.x milestone Aug 25, 2026
@seratch
seratch merged commit 150a4f4 into openai:main Aug 25, 2026
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow SingleAgentVoiceWorkflow to receive Runner context

2 participants