MTP exposes a provider-agnostic event stream through:
pythonagent.run_events(prompt, max_rounds=5, stream_final=True)or:
pythonagent.print_response(prompt, stream=True, stream_events=True)All providers map into the same event shape.
print_response(..., stream_events=True) now defaults to human-readable terminal formatting. Use event_format="json" to print raw JSON lines. Pretty logs use explicit level prefixes such as INFO |, DEBUG |, and ERROR |.
Event verbosity follows debug_mode:
debug_mode=False(normal): concise lifecycle logs (run_started,round_started, streamed text, completion/cancel/pause/retry, strict violations).debug_mode=True(debug): full trace, including plans, batch starts, assistant tool-call messages, and tool start/end payloads.- Debug trace includes only top-level XML sections for separation of concerns (
<tools>,<team_members>,<system_instructions>,<user_instructions>,<orchestration_instructions>), plus metrics blocks.
Base fields
Every event includes:
type: event kindtimestamp: ISO 8601 UTC timestamprun_id: stable id for the runsequence: monotonic event index within the run- Optional run context fields on
run_started:user_id,session_id,metadata - Optional validation field on
run_started:input_validation_error
Event types
run_starteduser_messagemax_roundstools_availabletool_namesdirect_tool_namesdelegation_tool_namessystem_instructionsuser_instructionsautoresearchresearch_instructionsorchestration_instructionsmember_agents: list of{id, mode, delegation_tool, role, tools}stream_tool_eventsstream_tool_results
round_startedround
llm_responseroundstage: optional ("finalize"for final response generation)providermodelusage: optional{input_tokens, output_tokens, total_tokens, reasoning_tokens}duration_secondshas_planhas_response
plan_receivedroundbatches: list of{mode, calls, call_ids}
strict_violationsroundviolations: list of{call_id, tool_name, message}
assistant_tool_messageroundmessage: raw assistant tool call message
batch_startedroundbatch_indexmodecall_ids
tool_startedroundbatch_indexcall_idtool_nameargumentsdepends_onreasoning(optional concise rationale summary)
tool_finishedroundcall_idtool_namesuccesscachedapprovaloutput(present only when tool-result streaming is enabled)error(present only when tool-result streaming is enabled)reasoning(optional concise rationale summary)
text_chunkchunksource:direct | finalize_stream | finalize_fallback
run_completedfinal_textroundstotal_tool_calls
run_terminatedroundreasontool_name
run_cancelledround
run_failedrounderror_typeerror
tool_retry_requestedroundtool_namefeedback
run_pausedroundreasontool_name
Why this is provider-agnostic
Providers only produce actions/plans and optional token streams. The Agent owns event emission, so frontend code can consume one stable event model regardless of provider.
Related: