Oda SDK: Python reference

The Oda Python SDK drives DataMind Oda from your own Python program: it starts an Oda runtime as a subprocess and speaks newline-delimited JSON-RPC with it over standard input and output. This page is the reference for the run result, the runtime's lifecycle, the errors you can meet and the wire surface. If you are new to the family, start with the Oda SDK overview; install and a first run are in Oda SDK: Python.

The runtime's lifecycle

What a run returns

A run returns a RunResult:

PartWhat it holds
session_idThe session the run worked in.
final_responseThe text of the last assistant message in the run, with its text blocks joined; an empty string when the run has no assistant message.
finish_reasonHow the last turn ended: a kind such as completed, max-tokens or error, or None when the run has no turn end.
eventsThe events of your own session, in the order they arrived.
notificationsThe notifications of your session and of every helper agent below it, in the order they arrived on the wire.

When the runtime cannot start

Each failure below stops the launch, and the message names what is wrong.

Errors while it runs

Protocol notes

Questions, answered

What does a run return?

Five parts: the session id, the final response, the finish reason, your session's events and the notifications for your session and its helper agents. The table above lists each one.

When does a run finish?

When the session goes idle, the moment the whole session has settled. The run covers the interval from your prompt's receipt to that point.

How long does the runtime stay up?

One client keeps one runtime across all of its runs: it starts lazily on the first run and lives until you close the client or leave its context manager. Closing stops it in stages, and closing again is safe.

Which sessions do the notifications cover?

Your session and every helper agent below it, in the order they arrived on the wire. The client follows the tree from the helper start notifications. Events, by contrast, stay limited to your own session.

What happens if the runtime package is not installed?

The launch fails and the error says the bundled runtime cannot be located and names the runtime package to install.

What does the start-up handshake carry?

The working folder (cwd), the provider, the model, and, when you set them, the reasoning effort (reasoningEffort) and the token cap (maxTokens).

What happens to calls that are waiting when the runtime exits?

They fail with a transport error that says the runtime's output closed or that the runtime is closed, and the error carries the runtime's exit code and the tail of its error output. Nothing is retried for you.

Why did a turn end fail with a protocol error?

The runtime sent a turn end whose reason is not a string kind, which the protocol does not allow. The run fails with turn/end event requires a string data.reason.kind. Run the task again; if it repeats, keep the error text for a problem report.

What happens to a notification that nothing is reading?

It stays queued in the client instead of being dropped, so a later reader can pick it up.

Can I pass a configuration object and keyword options together?

No. The client takes one form or the other; passing both is refused.