Context
Tools where additional context improves results.
Problem
Agents may not know to request context they'll need.
Solution
Inject context automatically:
- User context: Current user's team, permissions
- Temporal context: Current time, timezone
- Environmental: Region, feature flags
- Relational: Related entities
- User context: Current user's team, permissions
- Temporal context: Current time, timezone
- Environmental: Region, feature flags
- Relational: Related entities
Examples
Python
@tool
def search_tasks(
query: str,
# Context auto-injected, can be overridden
team_id: str | None = None,
include_completed: bool = False
) -> TaskList:
"""Search tasks. Defaults to current user's team.
Context is automatically injected:
- team_id: Current user's team (from session)
- timezone: For date interpretation
"""
tid = team_id or session.get("team_id")
tz = session.get("timezone", "UTC")
results = tasks_api.search(query, team_id=tid, tz=tz)
return TaskList(
tasks=results,
context=SearchContext(team_id=tid, timezone=tz)
) Considerations
- Expand machine identifiers with human-friendly names/representations when possible
- Document what context is injected
- Allow explicit overrides
- Include injected context in the response