Skip to main content

tail_run_logs

Function tail_run_logs 

Source
pub fn tail_run_logs(
    run_id: &str,
    selector: StageSelector,
    stream: LogStream,
    max_bytes: u64,
) -> String
Expand description

Read a run’s logs, choosing the stage and the stream.

Exists because there were two answers in the codebase to “where is a run’s output”, and one of them was wrong: GET /api/agents/{id}/logs read <run_dir>/output.log, which nothing has ever written, so it returned an empty string for every run there has ever been. The real logs are per-stage, under stages/<idx>/. Routing both that handler and agent_result through here leaves one answer.

Stages come from stages.json rather than a read_dir of stages/, because that index is the record of which stages exist and in what order - the directory is just where their bytes landed.

max_bytes applies to what is returned, so for StageSelector::All it bounds the joined text rather than each stage separately: “the last N bytes of what you asked for” holds whatever the selector was.