Skip to main content

conversation_api/execution/
context.rs

1//! Invocation identity and tracing context.
2
3use serde::{Deserialize, Serialize};
4
5use crate::execution::{
6    ClientId, ConversationSurface, OperationId, RunId, ScopeId, TenantId, ThreadId, UserId,
7};
8
9/// Ownership boundary used for authorization and persistence partitioning.
10#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
11pub struct Scope {
12    /// Optional tenant for multi-tenant deployments.
13    pub tenant_id: Option<TenantId>,
14    /// Application scope that owns Agent state and application capabilities.
15    pub scope_id: ScopeId,
16}
17
18/// Authenticated actor that initiated an Agent run.
19#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
20pub struct Actor {
21    /// Authenticated user identity.
22    pub user_id: UserId,
23    /// Optional originating application client used for routed responses.
24    pub client_id: Option<ClientId>,
25}
26
27/// Context that follows one Agent invocation across all ports.
28#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
29pub struct InvocationContext {
30    /// Authorization and persistence scope.
31    pub scope: Scope,
32    /// Authenticated actor; never accepted from model-generated arguments.
33    pub actor: Actor,
34    /// Trusted, canonical conversation space. Runtime uses it only as thread identity.
35    pub surface_id: ConversationSurface,
36    /// Durable conversation thread.
37    pub thread_id: ThreadId,
38    /// Current run identifier.
39    pub run_id: RunId,
40    /// Idempotency identifier for the initiating operation.
41    pub operation_id: OperationId,
42    /// Optional absolute Unix deadline in milliseconds.
43    pub deadline_unix_ms: Option<u64>,
44    /// Optional W3C traceparent propagated by the deployment.
45    pub traceparent: Option<String>,
46}