rho-coding-agent 3.12.0

A fast Rust agent harness with a small footprint and opinionated defaults
Documentation
//! How many tool calls of its own the agent has in progress.

use agent_client_protocol::v1::schema::{
    SessionUpdate, ToolCall, ToolCallStatus, ToolCallUpdate, ToolCallUpdateFields,
};
use pretty_assertions::assert_eq;

use super::OwnCalls;

// Covers: a call of the agent's own counts from its announcement, pending or
// running, until the agent completes or fails it; a call of a served tool,
// announced too, never counts (the tools count it themselves), nor does one
// announced already ended or an update that ends nothing; the count is told
// only when it changes. The daemon lends a budgeted turn's slot only while
// the count is none (`budget_tests`), since a Claude Code Task subagent
// makes model requests while its agent waits on rho's tools.
// Kills: `served.is_none()` dropped from the announce arm (a served call counts as
// the agent's own, so a turn never lends while the agent waits on rho);
// the end arm dropped (an ended Task still counts, so the turn never lends
// again); any update read as an end (a running Task stops counting at its
// first progress update); the announce arm's status check dropped (a call
// announced as it ended counts for good).
// Owner: ACP runtime, the agent's activity its tools hear.
#[test]
fn the_agents_own_calls_count_from_their_announcement_to_their_end() {
    let announced = |id: &'static str, status, served: Option<&'static str>| {
        let call = ToolCall::new(id, "Task").status(status);
        (SessionUpdate::ToolCall(call), served)
    };
    let updated = |id: &'static str, status: Option<ToolCallStatus>| {
        let fields = match status {
            Some(status) => ToolCallUpdateFields::new().status(status),
            None => ToolCallUpdateFields::new(),
        };
        (
            SessionUpdate::ToolCallUpdate(ToolCallUpdate::new(id, fields)),
            /*served*/ None,
        )
    };
    let heard = [
        announced("task", ToolCallStatus::Pending, /*served*/ None),
        announced("rho-wait", ToolCallStatus::InProgress, Some("sessions")),
        updated("task", Some(ToolCallStatus::InProgress)),
        updated("task", None),
        announced("read", ToolCallStatus::InProgress, /*served*/ None),
        announced("done", ToolCallStatus::Completed, /*served*/ None),
        updated("rho-wait", Some(ToolCallStatus::Completed)),
        updated("read", Some(ToolCallStatus::Failed)),
        updated("task", Some(ToolCallStatus::Completed)),
    ];

    let calls = OwnCalls::default();
    let told: Vec<Option<usize>> = heard
        .iter()
        .map(|(update, served)| calls.hear(update, *served))
        .collect();

    assert_eq!(
        told,
        vec![
            Some(1),
            None,
            None,
            None,
            Some(2),
            None,
            None,
            Some(1),
            Some(0)
        ]
    );
}