Skip to main content

sync_agent_reactive

Function sync_agent_reactive 

Source
async fn sync_agent_reactive(
    base: &str,
    agent_id: &str,
    token: &str,
    http: &Client,
    mstore: &Arc<Store>,
    handler: &'static ReactiveHandler,
) -> AgentSyncOutcome
Expand description

One registered agent’s full pending-fetch → claim → deliver cycle for an InjectAvailable broadcast. Extracted from the loop body it used to be so handle_server_msg can run every agent’s sync concurrently via join_all instead of sequentially — see the call site’s own comment.

Retries once with the shared token if a per-agent credential is rejected (401 or 403 — see is_credential_rejected) — without this, invalidating the credential alone left this agent’s pending injection undelivered until an unrelated InjectAvailable broadcast happened to fire again (no periodic resync exists). reagentx P1 (round 4) on PR #2342; 403 coverage added later (without it, a genuine binding mismatch degrades to a silent stall instead of falling back the same way an expired token already does).

base is the relay’s REST base URL (super::relay::rest_base_url); a parameter so a test can point one sync at a fake relay.