agentsclimarketplace

Streaming agent response

Skill kjuhwa/skills-hub/skills/agents/streaming-agent-response

Stream agent output token-by-token or item-by-item using Runner.run_streamed().From its SKILL.md

Install
npx -y skills add kjuhwa/skills-hub --skill streaming-agent-response

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.5 KB, 420 tokens by cl100k_base, as published. Nobody here has run it

streaming-agent-response

Use Runner.run_streamed() to get a RunResultStreaming object. Iterate result.stream_events() to receive raw token deltas or higher-level run items as they arrive.

When to apply

Chat UIs needing progressive text display, long-running agents where the user should see progress, or any scenario where latency-to-first-token matters.

Token-level streaming

import asyncio
from openai.types.responses import ResponseTextDeltaEvent
from agents import Agent, Runner

async def main():
    agent = Agent(name="Joker", instructions="You are a helpful assistant.")
    result = Runner.run_streamed(agent, input="Please tell me 5 jokes.")
    async for event in result.stream_events():
        if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent):
            print(event.data.delta, end="", flush=True)

asyncio.run(main())

Item-level streaming

from agents import Agent, ItemHelpers, Runner

async def main():
    agent = Agent(name="Joker", instructions="First call how_many_jokes, then tell jokes.", tools=[...])
    result = Runner.run_streamed(agent, input="Hello")
    async for event in result.stream_events():
        if event.type == "raw_response_event":
            continue
        elif event.type == "run_item_stream_event":
            if event.item.type == "tool_call_item":
                print(f"Tool called: {event.item.raw_item.name}")
            elif event.item.type == "message_output_item":
                print(f"Message: {ItemHelpers.text_message_output(event.item)}")

Key notes

  • Always drain stream_events() to completion; the run is not complete until the iterator ends
  • RunResultStreaming.interruptions is populated after the stream ends if tool approval is needed
  • Call result.cancel(mode="after_turn") to stop cleanly after the current turn
  • result.is_complete reflects final run state only after the iterator finishes

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,144. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.