openagents_sdk::agents::runner
Typed, bounded stdio contract for an operator-installed Rust agent. A definition identifies a runner; it never supplies its executable or arguments.
| Item | What it does |
|---|---|
Event enum | A message a runner writes back: progress text or a final result. |
Turn struct | One request to a runner: the assignment, the agent, the task, and the working folder. |
serve_once fn | Read one bounded JSON request, invoke application code, and write one result. |
MAX_FRAME const | The largest request or result line, in bytes. |
MAX_OUTPUT const | The most output a runner may produce, in bytes. |
VERSION const | The schema version a runner request must carry. |
Event
pub enum Event {
Text { text: String },
Completed { result: String },
Failed { message: String },
}
A message a runner writes back: progress text or a final result.
Event::text
pub fn text(&self) -> &str
Returns the event's text, result, or error message.
Event::terminal
pub fn terminal(&self) -> bool
Returns true when the event ends the turn.
Turn
pub struct Turn {
pub schema: String,
pub assignment: String,
pub conversation: String,
pub agent: AgentSpec,
pub task: String,
pub cwd: String,
}
One request to a runner: the assignment, the agent, the task, and the working folder.
Turn::validate
pub fn validate(&self) -> Result<(), &'static str>
Checks the request and returns a message for the user when it is not valid.
serve_once
pub fn serve_once<R: BufRead, W: Write>(
mut input: R,
mut output: W,
run: impl FnOnce(Turn) -> Result<String, String>,
) -> std::io::Result<()>
Read one bounded JSON request, invoke application code, and write one result. Logs belong on stderr. The host terminates the process when the user stops it.
MAX_FRAME
pub const MAX_FRAME: usize = 96 * 1024;
The largest request or result line, in bytes.
MAX_OUTPUT
pub const MAX_OUTPUT: usize = 1024 * 1024;
The most output a runner may produce, in bytes.
VERSION
pub const VERSION: &str = "openagents.agent.runner.v1";
The schema version a runner request must carry.