Every run of your agent is a sequence of events: the text it writes, each tool call it makes and the tool’s result, the steps it passes through, and one event that ends it. Onecortex produces them from your framework, so callers see the same events whichever framework you use.
A streaming caller gets each event as it happens, as server sent events. A JSON caller gets the tool calls, results and steps in events, and the text whole in result. See the invoke API.
The events
Every event is a JSON object with v, the event format version, which is 1, and type.
text
A piece of the reply.
Join the delta values in order for the whole reply. done.result also carries it whole.
A tool call begins.
id is unique within the run, and ties the call’s other events together.
A piece of the call’s arguments, as JSON text.
Join the delta values for one id to get its arguments. A framework that does not stream arguments sends them whole in one event.
The call’s arguments are complete.
The tool’s output.
output is a string: JSON text when the tool returned structured data. isError is true when the tool failed. Output longer than 64 KB is cut to 64 KB.
step_start and step_end
A named stage of the run begins or ends: a LangGraph node, an OpenAI Agents SDK agent after a handoff, a CrewAI task.
Steps can nest. Each framework page says what its steps are.
done
The run finished.
result is always present, and is the whole reply. On the stream, done also carries sessionId, versionNumber and durationMs.
error
The run failed.
code is one of the invoke error codes, most often agent_error, when your code raised. Your traceback is in your logs, never in the event.
A stream that has started has already sent 200 OK, and cannot change it. If the run fails after that, the failure arrives in the stream as event: error. Handle it: a client that reads only text and done shows a failed run as an empty success.
The rules
- Exactly one terminal event, last. Every run ends in
done or error, and nothing follows it. A run that stops without one is reported as an error with upstream_error, The agent stopped before finishing its reply.
- A tool call starts before anything else about it.
tool_call_args, tool_call_end and tool_result for an id always follow its tool_call_start.
- A failed run may leave a call or a step open. Do not wait for an
end after an error.
- Every framework sends at least
text and done. What more it sends depends on what the framework reports: see its page.
On the wire
Each event is one server sent events frame, named by its type, with the event as single line JSON:
While your agent is silent, Onecortex sends : ping every 15 seconds. It is a comment, which server sent events clients ignore, and it keeps proxies from closing the connection.
Send your own events
A plain function agent can report its own tool calls and steps by yielding event objects alongside its text. See A Python function and A TypeScript function.