Skip to content

add ctx.with_filler() for acoustic fillers during long tools#5885

Merged
longcw merged 7 commits into
mainfrom
longc/ctx-with-filler
Jun 4, 2026
Merged

add ctx.with_filler() for acoustic fillers during long tools#5885
longcw merged 7 commits into
mainfrom
longc/ctx-with-filler

Conversation

@longcw

@longcw longcw commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds ctx.say_filler() — an async context manager on RunContext that schedules optional filler speech during a long-running tool call. Fills quiet conversation gaps without burning an LLM round-trip.

@function_tool
async def book_flight(ctx: AsyncRunContext, origin, destination, date) -> str:
    await ctx.update(f"Searching flights from {origin} to {destination}…")
    async with ctx.say_filler("Still searching, hang on a sec.", delay=5):
        await slow_search()
    return result

Design

  • Two lanes. ctx.update() is the chat-ctx channel — delivers a real status to the LLM, which voices it. ctx.say_filler() is the acoustic channel — fires session.say() directly, bypasses the LLM.
  • Idle-gated. Each fire waits for delay seconds of continuous session-idle before playing, so fillers don't talk over the user or queue behind other speech. State changes (agent_state_changed, user_state_changed) reset the dwell.
  • One-shot or repeating. interval=None (default) fires at most once; setting interval makes the scheduler loop with wall-clock cooldown between fires. max_steps caps the number of fires.
  • Flexible source. Accepts str or (step: int) -> SpeechHandle | str | None. Callable returning None skips; useful for rotating variants.

@chenghao-mou chenghao-mou requested a review from a team May 29, 2026 03:18
devin-ai-integration[bot]

This comment was marked as resolved.

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

Lgtm! let's do async with ctx.with_filler as discussed on Slack

@longcw longcw changed the title add ctx.say_filler() for acoustic fillers during long tools add ctx.with_filler() for acoustic fillers during long tools Jun 4, 2026
@longcw longcw merged commit 3bc0a5c into main Jun 4, 2026
23 checks passed
@longcw longcw deleted the longc/ctx-with-filler branch June 4, 2026 02:21
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.

2 participants