agent_runtime/tool/tool_context.rs
1//! Trusted host-provided metadata passed to every tool invocation.
2
3use uuid::Uuid;
4
5use super::FamilyContext;
6
7/// Trusted execution metadata supplied by the platform, never by the model.
8#[derive(Debug, Clone, Default, PartialEq, Eq)]
9pub struct ToolContext {
10 /// Persistent EME user identifier resolved from the authenticated platform identity.
11 pub user_id: Option<String>,
12 /// IANA timezone configured in the authenticated user's platform profile.
13 pub timezone: Option<String>,
14 /// Host-resolved Telegram user ID linked to the authenticated conversation owner; never model-controlled.
15 pub telegram_id: Option<String>,
16 /// Family selected for this run and verified for this user.
17 pub family: Option<FamilyContext>,
18 /// Family rosters the host authorizes this run to use. The host may scope this
19 /// to a selected family even when the user belongs to additional families.
20 /// Telegram recipient authorization is checked against these trusted rosters.
21 pub families: Vec<FamilyContext>,
22 /// Conversation whose turn caused this tool invocation.
23 pub conversation_id: Option<String>,
24 /// Stable identifier of the enclosing agent run.
25 pub run_id: Option<Uuid>,
26}
27
28impl ToolContext {
29 pub fn new(user_id: impl Into<String>) -> Self {
30 Self {
31 user_id: Some(user_id.into()),
32 ..Self::default()
33 }
34 }
35}