0.4.1 → 0.4.2 — Front-end Tools & Custom AG-UI Events¤
Summary¤
Two additive features for Agno modules using the AG-UI stream:
- Front-end tools — first-class integration of Agno's community tool helpers,
with the
tools=factory now able to accept an optionalRunContextso per-run state can flow into tool construction without mutating theAgentinstance. - Custom AG-UI events — a new
CustomEventtype and the matching handler inAgUiMixin, so modules can emit arbitrary client-facing events alongside the built-in lifecycle ones.
A handful of AG-UI streaming fixes ship in the same release (tool-call dedup, HITL flow, reasoning update).
No breaking changes; everything is opt-in.
What changes¤
1. CustomEvent and AgUiMixin handler¤
Modules that need to push protocol-level signals to the front (beyond the
generic TEXT_MESSAGE_*, TOOL_CALL_*, RUN_* events) can now emit a
CustomEvent:
from digitalkin.models.events import CustomEvent
await context.callbacks.send_message(
CustomEvent(name="my_signal", value={"foo": "bar"})
)
AgUiMixin ships with the corresponding handler that translates the event into
an AG-UI CUSTOM frame on the client stream. Existing modules see no change —
the handler is only invoked when a CustomEvent is produced.
2. Front-end tools — community Agno integration¤
Agno's community function helpers (the ones that wrap user-declared tool
definitions into Function objects) are now integrated into the SDK's tools
factory. Two practical consequences:
- The factory accepts an optional
run_contextargument. If provided, it is threaded through tool construction, so tools that need per-run state (storage handles, cost trackers, the AG-UI input itself) can be built inline instead of throughdependencies-based indirection. - The factory no longer assumes the
Agentinstance is the only source of truth for tools; combined withcache_callables=False, this makes it straightforward to wire dynamic frontend-tool catalogues.
3. AG-UI streaming fixes¤
- Tool-call dedup: in stream sessions where the LLM re-emits the same
tool_call_id(Agno retry / re-plan paths), the adapter no longer forwards duplicateTOOL_CALL_START/TOOL_CALL_ENDevents to the front. Only the first occurrence is emitted; later duplicates are silently dropped. - HITL tool flow: the resume path correctly threads
tool_call_ids throughacontinue_run, fixing a case where pending tool results were injected on the wrongToolExecutioninstance after a storage round-trip. - Reasoning update: the reasoning sequence is closed deterministically
by the next non-reasoning event, fixing a class of orphaned
REASONING_MESSAGE_CONTENTevents that the front could not render.
Migration¤
None required. To opt into custom events, import CustomEvent from
digitalkin.models.events and emit via context.callbacks.send_message. To
opt into the run-context-aware factory, pass run_context=... to
make_tools_factory(...) at agent construction.