Override budget guards, downgrade maps, and workflow metadata per call using contextvars (Python) or AsyncLocalStorage (Node).
Agent hint
Use for multi-tenant wrap(), per-request budget_guard overrides, and avoiding global config mutation.
In scope
Out of scope
res = auditor.wrap(
call_fn=openai.chat.completions.create,
build_params=lambda: {
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Process request"}],
},
options={
"workflow_id": "tenant_abc",
"budget_guard": {"max_cost_per_session": 0.05, "on_budget_exceeded": "throw"},
"downgrade_map": {"gpt-4o": "gpt-4o-mini"},
},
)const response = await auditor.wrap(
(params) => openai.chat.completions.create(params),
() => ({ model: "gpt-4o", messages: [{ role: "user", content: "Process request" }] }),
{
workflowId: "tenant_abc",
budgetGuard: { maxCostPerSession: 0.05, onBudgetExceeded: "throw" },
downgradeMap: { "gpt-4o": "gpt-4o-mini" },
},
);