Skip to main content

run_tool_continue

Function run_tool_continue 

Source
pub async fn run_tool_continue(
    state: &Arc<ServerState>,
    tracker: &Arc<ReadTracker>,
    caps: &Arc<CapabilitySet>,
    caller_id: Option<&str>,
    tool_id: String,
    cursor: String,
) -> Response
Expand description

SP-pagination-v1 §4.4 — handle a Request::RunToolContinue.

Steps:

  1. Verify the cursor (HMAC + TTL + session nonce) → CursorPayload.
  2. Reject if the cursor’s tool_id ≠ request’s tool_id (anti-replay).
  3. Look up the tool; reject if not found, or if it doesn’t override supports_pagination() (a cursor against a non-paginating tool is bug-or-attack territory; 1021).
  4. Re-check required_capabilities against the current connection’s capability set — caps may have changed since the cursor was issued (UCAN revocation, Hello re-negotiation).
  5. Acquire the per-tool semaphore (same rate-limit envelope as run_tool).
  6. Build a CallContext with the cursor issuer attached.
  7. Call tool.call_paginated(Value::Null, &ctx, Some(&cursor_str)). Args are intentionally Null on continuation — original args were fingerprinted into the cursor and the tool is expected to read its state from cursor.opaque_state.
  8. Emit one audit event tagged with cursor_page = payload’s page_index.
  9. Return ToolResultResponse with the new next_cursor from the tool.