output
Read a background job's accumulated stdout and stderr with cursor-based pagination, enabling incremental fetching of new events without blocking.
Instructions
Get a background job's accumulated stdout/stderr output, paginated by a monotonic cursor. Pass after_cursor (from a PRIOR CALL WITH THE SAME stream SELECTION's own next_cursor) to fetch only new events since your last read of that same selection - a cursor is scoped to the exact stream value that produced it, and reusing it with a DIFFERENT stream value can skip an already-retained event on the other stream (start from 0/omit after_cursor instead when switching selections). stream selects stdout, stderr, or both (merged in real line-materialization order, default). Once a selected stream has lost some of its own history - either under its own byte/line cap while the job is still running, or because the job finished and its output later became eligible for job-output retention (see GHANTIKA_JOB_RETENTION_MS/GHANTIKA_MAX_RETAINED_JOBS) - the response discloses a bounded "dropped" count for that stream plus "droppedBeforeCursor" (the lowest seq still retained, or the stream's highest-ever-assigned seq - possibly 0 if no line was ever materialized - when nothing survives) - never which specific lines were lost, and never which of the two causes applied. "dropped" is ordinarily a count of complete lines, but it also counts two narrower events the same way: a not-yet-newline-terminated fragment discarded on reclaim, and a chunk arriving for a stream after its job is already reclaimed - neither is a materialized line, but each is real, permanent loss, so both count too rather than leaving the stream falsely indistinguishable from one that never received anything. For stream:"stdout"/"stderr" this is a scalar pair at the top level; for stream:"both" it is a nested object keyed by stream ({stdout?:{...}, stderr?:{...}}), since each stream's own loss is independent. Three distinct signals, never conflate them: "dropped" means this stream lost something forever; "truncated" means this specific call's own response window (from limit, or from that same loss) does not contain everything currently available; "next_cursor" is simply where to resume paging with the SAME stream selection - it carries no information about loss on its own.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"job_id": "<job_id>"
},
"name": "output"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Cap the number of events returned in this call (a positive integer). Omit for no cap - next_cursor still lets you page through incrementally either way. | |
| job_id | Yes | The job id returned by a prior run call. | |
| stream | No | Which stream to read. Defaults to "both" (merged in real line-materialization order - stdout and stderr never collide on seq, so no synthetic interleave is needed). | |
| after_cursor | No | Only return events after this cursor (from a PRIOR CALL WITH THE SAME stream selection's own next_cursor - a cursor is scoped to the exact selection that produced it, and reusing it with a different stream value can skip an already-retained event on the other stream). Omit or 0 to read from the earliest still-retained event, or when switching stream selections. Must be a non-negative integer. |