Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sync-agent-registration-before-ready.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@voltagent/core": patch
---

Register agents synchronously during VoltAgent construction so getAgent and getAgents can return agents with global defaults before ready resolves.
7 changes: 7 additions & 0 deletions packages/core/src/voltagent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ describe("VoltAgent defaults", () => {
expect.arrayContaining(["ls", "read_file", "execute_command", "workspace_search"]),
);

const retrievedAgent = voltAgent.getAgent("assistant");
expect(retrievedAgent).toBe(agent);
expect(retrievedAgent?.getWorkspace()).toBe(workspace);
expect(retrievedAgent?.getTools().map((tool) => tool.name)).toEqual(
expect.arrayContaining(["ls", "read_file", "execute_command", "workspace_search"]),
);

await voltAgent.ready;
await voltAgent.shutdown();
});
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/voltagent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ export class VoltAgent {
// Setup graceful shutdown handlers
this.setupShutdownHandlers();

// Register agents synchronously so getAgent/getAgents can be used immediately after construction.
// Workspace defaults are applied before registration; workspace initialization is still awaited by ready.
this.registerAgents(options.agents);

const finalizeInit = () => {
// ✅ NOW register agents - they can access global telemetry exporter
this.registerAgents(options.agents);
this.registerTriggers(options.triggers);

// Register workflows if provided
Expand Down
Loading