Agent$run() yields these events as the agent works, and an
AgentResult keeps them in events. Each event has a type, a
timestamp and a named list of data. Check event$type to tell events
apart, and read data fields directly with $, for example event$text. A
field that isn't there returns NULL. Events are read-only.
Event types
"start": the run started.task."request_start","request_end","request_error": a model request started, finished or failed, with the provider, model and request number."request_error"carries the originalcondition. ellmer's HTTP retries are not separate requests."text": a streamed chunk of the reply.text,is_complete."text_complete": the full reply.text."content": other content from the provider.content,content_type."tool_start": a tool call is about to run.tool_call_id,tool_name,tool_input."tool_end": a tool call finished.tool_call_id,tool_name,tool_result,tool_error."turn": a turn finished.turn,turn_number."permission","hook": a permission decision or hook result."approval": a tool call is waiting for approval.approval_id,path,tool_name,tool_input,reason."trusted_result": a trusted tool returned a value (see TrustedResults).result_id,result_type,tool_name,value."compaction_start","compaction","compaction_error": automatic compaction started, finished or failed."fallback": a fallback Chat took over after a transient error.fallback_index,condition,usage."structured_attempt": one attempt at structured output, with thevalue, whether it wasvalidand anyfeedback. It may hold sensitive data."file_checkpoint": a file checkpoint was created at the start of the run.checkpoint_id,name."run_error": the run failed.phaseand the originalcondition."usage": the run's usage.usage,limits."stop": the run ended.reason,cost,usage, andlimit(details of the usage limit that stopped the run, orNULL).
Events also carry the run_id. All but "text", "text_complete" and
"content" carry agent_id, session_id and run_context too, plus
parent and delegation IDs in subagent runs.