Loading…
Loading…
Features · Build · Streaming
agent.stream() runs the same loop as run() and yields an event for each step as it happens: the model's responses, every tool call and its output, the answer as it is written, and a summary at the end.
from shipit_agent import Agentfrom shipit_agent.llms import build_llm_from_envagent = Agent.with_builtins(llm=build_llm_from_env(), project_root=".")for event in agent.stream("Run the tests and summarise what fails."): print(f"{event.type:22} {event.message}")
agent.stream()
same loop as run()
Events
tool_called, text_delta…
Your UI
terminal, web, notebook
run_completed
the answer and its cost
The code is a checked example from the docs; the output is an example of what it prints.
from shipit_agent import Agent
from shipit_agent.llms import build_llm_from_env
agent = Agent.with_builtins(llm=build_llm_from_env(), project_root=".")
for event in agent.stream("Run the tests and summarise what fails."):
print(f"{event.type:22} {event.message}")6 more ways to use it
Each example is from the docs and checked against the library.
event.type # "tool_called"
event.message # "Tool called: bash"
event.payload # {"tool": "bash", "call_id": "...", "arguments": {"command": "pytest -q"}}
event.timestamp
event.to_dict() # for JSON, SSE or WebSocketIn a terminal
shipit chat renders the same events as a compact transcript.
Over the web
agent.stream_sse() yields Server-Sent Events ready for a response.
From async code
agent.astream() is the async counterpart.
Tool output as it arrives
Long commands stream their output, line by line.
| Parameter | Default | What it does |
|---|---|---|
| progress_summaries | False | Emit public `agent_decision` / `agent_observation` progress events. Decisions use only prose the primary model already produced; observations use factual tool metadata. |
| stream_queue_maxsize | 256 | How many events `stream()` buffers before the run waits for the reader. |
| cancel_on_stream_close | True | Cancel the run when the reader stops iterating `stream()`. |
| stream_join_timeout | 2.0 | Seconds to wait for the run's thread when a stream closes. |