Skip to content

cayu.testing.ToolContext

Part of cayu.testing.base. Read the Python API overview and install the required extra.

from cayu.testing import ToolContext

Bases: BaseModel.

Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.

Name Type Default
execution_deadline ExecutionDeadline Field(default_factory=current_execution_deadline, exclude_if=lambda boundary: boundary.expires_at is None)
image_decode_limits dict[str, int] | None Field(default=None, exclude_if=lambda value: value is None)
session_id str required
agent_name str | None None
environment_name str | None None
causal_budget_id str | None None
workspace_id str | None None
artifact_store_id str | None None
idempotency_key str | None None
workspace WorkspaceHandle | None Field(default=None, exclude=True)
artifact_store ArtifactStoreHandle | None Field(default=None, exclude=True)
runner RunnerHandle | None Field(default=None, exclude=True)
invocation_secret_redactor Callable[[], Any] | None Field(default=None, exclude=True)
invocation_secret_snapshot_provider Callable[[], Any] | None Field(default=None, exclude=True)
invocation_secret_capture_observer Callable[[int], None] | None Field(default=None, exclude=True)
vault VaultHandle | None Field(default=None, exclude=True)
proxy CredentialProxyHandle | None Field(default=None, exclude=True)
knowledge_store KnowledgeStoreHandle | None Field(default=None, exclude=True)
knowledge_access_scope Any Field(default=None, exclude=True)
mcp_servers tuple[Any, ...] Field(default_factory=tuple, exclude=True)
metadata dict[str, Any] Field(default_factory=dict)
ToolContext.inference() -> InferenceInvoker | None

Optional runtime-owned inference handle, valid only during this tool call.

ToolContext.workspace_reference_binding() -> WorkspaceReferenceBinding

Observe the admitted workspace after factory materialization and binding.

A detached/deserialized context has no live authority and fails closed. Public workspace_id and application metadata cannot supply this authority.

ToolContext.require_workspace_binding(binding: WorkspaceReferenceBinding) -> None

Reject a foreign or unavailable binding before consuming its claims.

ToolContext.copy_metadata(value: dict[str, Any]) -> dict[str, Any]
ToolContext.validate_nonblank_session_id(value: str, info) -> str
ToolContext.validate_optional_nonblank_ids(value: str | None, info) -> str | None
ToolContext.copy_mcp_servers(value)

Release source · Runtime guarantees · Capability guides