Patch Changes
-
#1218
4860832Thanks @omeraplak! - feat(agent): expose request headers to dynamic agent configurationDynamic
instructions,model, andtoolsfunctions now receive aheadersmap in
DynamicValueOptionswhen an agent is called through the built-in HTTP endpoints. This makes it
possible to configure tenant-aware models and request-scoped tools from headers such as
authorization,x-tenant-id, orx-user-idwithout manually copying them into
options.context.Header names are normalized to lowercase:
const agent = new Agent({ name: "Tenant Agent", instructions: "You are a tenant-aware assistant.", model: ({ headers }) => { return headers?.["x-tenant-id"] === "enterprise" ? "openai/gpt-4o" : "openai/gpt-4o-mini"; }, tools: ({ headers }) => { return headers?.authorization ? [createTenantTool(headers.authorization)] : []; }, });
For direct in-process calls, pass
requestHeaders:await agent.generateText("Hello", { requestHeaders: { authorization: "Bearer token", "x-tenant-id": "tenant-1", }, });
Fixes #1201
-
Updated dependencies [
4860832,71c9f84]:- @voltagent/core@2.7.1
- @voltagent/server-core@2.1.14