#[non_exhaustive]pub struct CallContext {
pub cwd: PathBuf,
pub max_output_bytes: usize,
pub call_id: Ulid,
pub deadline: Option<Instant>,
pub read_tracker: Option<Arc<ReadTracker>>,
pub capabilities: Arc<CapabilitySet>,
pub tier: ToolTier,
pub caller_id: Option<String>,
pub secrets: Option<Arc<SecretBundle>>,
pub cursor_issuer: Option<Arc<CursorIssuer>>,
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.cwd: PathBufWorking directory for relative-path tools (Read / Bash / Glob / …).
max_output_bytes: usizeAdvisory truncation budget. Tools should respect this and return
truncation markers when producing larger output. In SP-12 this is
derived from the tool’s tier via TierPolicy::max_output.
call_id: UlidUnique id for tracing/logging; not emitted on the wire.
deadline: Option<Instant>Absolute deadline. Tools that wrap long operations in tokio::time::timeout
should pass remaining_time() as the budget.
read_tracker: Option<Arc<ReadTracker>>Shared-per-connection read tracker. None in isolated unit tests;
server always attaches one via Arc::clone in per-connection state.
capabilities: Arc<CapabilitySet>Connection-scoped capability allow-list. Populated from the Hello
handshake; shared across all calls on a single connection. Tools that
gate side effects on caller authority may read this, though dispatch
already enforces required_capabilities before invocation.
tier: ToolTierTier the current call resolved to. Informational for tools; dispatch uses the tier to pick the deadline / max_output budget above.
caller_id: Option<String>Optional per-call agent identity. Populated from the Hello.client_id
handshake; None for unit tests and in-process dispatch with no
client-id source. Audit events copy this field into CallEvent.caller_id.
secrets: Option<Arc<SecretBundle>>Optional per-call secret bundle resolved by ServerConfig::token_broker
(SP-token-broker-phase1). None means either (a) no broker is
configured on this server, or (b) the broker returned Ok(None) for
this caller — both cases pass through to the tool’s existing fallback
(env vars, saved file, etc.). Tools that need a secret access via
ctx.secrets(). Audit CallEvent.secrets_resolved is true iff
this is Some(_).
cursor_issuer: Option<Arc<CursorIssuer>>SP-pagination-v1 — cursor issuer for tools that override
Tool::call_paginated. None for non-paginating dispatch paths
(test fixtures, listeners that haven’t wired pagination). Tools
use ctx.cursor_issuer().issue(payload) to mint a next_cursor.
Implementations§
Source§impl CallContext
impl CallContext
Sourcepub fn new(
cwd: PathBuf,
max_output_bytes: usize,
call_id: Ulid,
deadline: Option<Instant>,
read_tracker: Option<Arc<ReadTracker>>,
capabilities: Arc<CapabilitySet>,
tier: ToolTier,
caller_id: Option<String>,
secrets: Option<Arc<SecretBundle>>,
) -> Self
pub fn new( cwd: PathBuf, max_output_bytes: usize, call_id: Ulid, deadline: Option<Instant>, read_tracker: Option<Arc<ReadTracker>>, capabilities: Arc<CapabilitySet>, tier: ToolTier, caller_id: Option<String>, secrets: Option<Arc<SecretBundle>>, ) -> Self
Construct a CallContext from its required fields. This is the
stable constructor across crate boundaries — the type is
#[non_exhaustive], so adding new fields in the future means
callers migrate through CallContext::new(...) (or a future
CallContextBuilder), not via struct-literal breakage.
Sourcepub fn with_cursor_issuer(self, issuer: Arc<CursorIssuer>) -> Self
pub fn with_cursor_issuer(self, issuer: Arc<CursorIssuer>) -> Self
Builder-style attach of the cursor issuer. Call after new from
dispatch code that wants to enable pagination for the call.
Sourcepub fn cursor_issuer(&self) -> Option<&CursorIssuer>
pub fn cursor_issuer(&self) -> Option<&CursorIssuer>
Convenience accessor for paginating tools. Returns the issuer if
one was attached by dispatch; tools that override call_paginated
but find this None must fall back to returning next_cursor: None
(or error if cursors are mandatory).
pub fn remaining_time(&self) -> Option<Duration>
Sourcepub fn secrets(&self) -> Option<&SecretBundle>
pub fn secrets(&self) -> Option<&SecretBundle>
Returns the resolved secret bundle, if any. None when no broker
is configured on the server, or when the broker returned None
for this caller.