Skip to main content

Context Propagation Guide

Practical guide to using context propagation in real-world applications.

Overview​

For detailed technical information about how context propagation works, see Context Propagation Deep Dive.

This guide focuses on practical patterns for using context in your applications.

Quick Start​

Setting Context​

withAgentContext(
"tenantId" to "ACME",
"userId" to "user-123"
) {
// All operations have context!
agent.processComm(comm)
}

Using Context in Tools​

val tool = contextAwareTool("my_tool") {
execute { params, context ->
val tenantId = context.tenantId!!
// Use tenantId for scoped operations
}
}

See Also​