- Symptom: terminal appears stuck after input.
- Cause: using sync generators inside an async context, or consuming an execution runtime stream without closing the execution.
- Fix:
- In async handlers, use
get_async_generator(...)andasync for. - Start with
await execution.async_start(...), consumeexecution.get_async_runtime_stream(...), and finish withexecution.async_close().
- In async handlers, use
- Symptom: every token prints its own label (e.g., repeated
[thinking]). - Cause: printing labels on every delta.
- Fix: print the label once, then append deltas on the same line; add a newline on completion.
- Symptom:
asyncio.run() cannot be called from a running event loop. - Cause: using sync
get_result().get_generator(...)inside an async handler. - Fix: use
request.get_async_generator(...)withasync for.
- Symptom: close returns a full state snapshot instead of a single scalar.
- Cause: execution lifecycle now treats close as the reliable completion boundary.
- Fix:
- Store user-facing output under a stable state key, such as
resultorfinal. - Use
set_result(...)only as a compatibility override when integrating old callers.
- Store user-facing output under a stable state key, such as
- Symptom: state does not contain the branch output you expected.
- Cause:
when()branches are event-driven and only update state if a handler writes state. - Fix: call
data.async_set_state(...)in event handlers and close the execution after pending tasks drain.
- Symptom: wrong handler called in batch/for_each.
- Cause: closure binding in loops.
- Fix: bind handler per chunk (factory or default argument).
- Symptom: data leaks across executions.
- Cause:
flow_datais global. - Fix: use execution state (
data.get_state,data.async_set_state) for per-execution state.
- Symptom: input never arrives or loop blocks.
- Cause: starting with
to(get_input)and waiting on events that are never emitted. - Fix: emit a loop event (e.g.,
Loop) at start, thenwhen("Loop") -> get_input.
- Symptom: each token prints a label.
- Fix: print label once, then stream tokens on the same line; print newline on completion.
- Symptom: model ignores tools or calls invalid tool.
- Fix:
- ensure tool names and schemas are clear in
.output()or.info() - keep tool list concise
- ensure tool names and schemas are clear in
- Symptom: repeated slow initialization.
- Fix: build KB once and reuse (e.g., cached collection in outer scope).
- Symptom: noisy httpx/httpcore logs.
- Fix: set
runtime.httpx_log_leveltoWARNINGorERROR.
- Symptom: model config seems ignored.
- Fix:
- call
Agently.set_settings(...)before creating agents - check runtime mappings (
debugtoggles multiple flags)
- call