Conversation
- Add registerCustomEndpoints export to core for legacy API - Update legacy server to merge global and instance endpoints - Clean up duplicate custom-endpoints code between packages - Fix tests to use new RouteDefinition object format - Add missing error handling to HonoServerAdapter routes
- Replace mock-socket with custom ws mocks for server-side testing - Remove _testOnlyAgentConnections export from production code - Add comprehensive WebSocket server behavior tests - Test connection handling, broadcasting, events, and error scenarios - Increase overall coverage from 39.35% to 93.54% - All 116 tests now passing including 24 WebSocket tests
- Change createVoltServer agents parameter from AgentDefinition[] to Record<string, Agent<any>> - Remove AgentDefinition type and agent creation logic - Inject shared registry into pre-instantiated agents - Update telemetry handling for agent instances - Add comprehensive test for subagent support - Update all tests to use Agent instances instead of definitions
|
|
Hey @alasano , thanks a lot for the PR! |
zrosenbauer
left a comment
There was a problem hiding this comment.
@alasano this is a huge win when we get this out and a ton to love in this PR. I tagged some general feedback and things we probably need to chat with @omeraplak on as they are huge changes to the underlying design/implemenation.
Some easier wins are:
- The default and IMO the default we will go forward with is NEVER use classes unless you need to maintain state (i.e. the Queue implmentation in #287)... we aren't making major changes to this YET but will in future: #192
- rename
server-hono(unless @omeraplak disagrees) toserveras the default VoltAgent server will behonobut the adapter allows custom integrations into any server
Overall 🙏 TY for your work on this as this is huge for the project (I'm anxiously waiting to finish my fastify PR!).
packages/core/src/index.ts
Outdated
|
|
||
| /** | ||
| * Main VoltAgent class for managing agents and server | ||
| * @deprecated The VoltAgent class is deprecated and will be removed in v2.0. Please use the new `createVoltServer` function from `@voltagent/server-hono` or your chosen server adapter. |
There was a problem hiding this comment.
@omeraplak @alasano do we want to remove this? This is the primary interface I use for setting up telemetry and also this assumes that every use case involves a server. Its 100% possibly to execute VoltAgent in things like:
- scripts
- cli
- browser (with some work we could)
Another note we are not at a v1 yet so I don't think we'd want to wait for major changes until v2
There was a problem hiding this comment.
Maybe not now, but possibly in the future. Making too many changes at once could be a bit risky.
| this.retriever = options.retriever; | ||
| this.voice = options.voice; | ||
| this.markdown = options.markdown ?? false; | ||
| this.registry = options.registry || new LocalAgentRegistry(); |
There was a problem hiding this comment.
I love this concept but @omeraplak I have an idea (unless I'm way off on the intention).
@omeraplak is the intention of the registry primarily around the LLMOps / Observability and console? If so we could lean towards giving the dev more control, with solid defaults.
Instead of requiring the registry make it 100% optional and completely decouple from the Agent. So for example if you want to add a team of Agents you'd do the following:
const subagent1 = new Agent();
const subagent2 = new Agent();
const supervisor = new Agent({
subagents: [subagent1, subagent2]
});
const registry = new VoltAgent({
agents: [subagent1, subagent2]
});
// Adding on the fly while decoupled:
const subagent3 = new Agent();
registry.registerAgent(subagent3); // first you add the agent to the registry
supervisor.addSubagent(subagent3); // second you add the subAgent where you want itThis would allow use to create agents without having to inject and pass around the registry which would IMO make it really hard to trace bugs etc. (state is a pain).
In addition if we wanted to keep the default functionality for a more zero-config set up we can provide this:
class AgentLite {} // no registry
class Agent extends AgentLite {} // has registry via instance and/or injectionThere was a problem hiding this comment.
Hmm, I’m not sure. I think it’s valuable for users to be able to use VoltOps effortlessly, without needing any configuration. That’s why I’d prefer not to separate it out too much. I’m not sure if what you’re suggesting goes against that idea or not.
| * Formats agent data for console consumption | ||
| * Ensures compatibility with console.voltagent.dev | ||
| */ | ||
| export class ConsoleDataFormatter { |
There was a problem hiding this comment.
Love this but I don't think it needs to be a class as there is no state management, I'd just create as a set of utils.
| @@ -0,0 +1,42 @@ | |||
| // Base adapter | |||
There was a problem hiding this comment.
👏 I love this set up as it makes it 100% clear what should be exposed in the package, great addition.
| /** | ||
| * Factory to create VoltAgent routes for any server framework | ||
| */ | ||
| export class VoltRouteFactory { |
There was a problem hiding this comment.
I think this could be a set of functions wrapped in a function as the class isn't really used outside of being init in the function.
I'd be fine for keeping as a class if we only export the type something like:
export type { VoltRouteFactory };Or export the type only in the index.ts
| // Export all schemas | ||
| export * from "./types"; | ||
|
|
||
| // Import route definitions |
There was a problem hiding this comment.
| // Import route definitions |
| @@ -0,0 +1,56 @@ | |||
| // Export all schemas | |||
There was a problem hiding this comment.
| // Export all schemas |
Hey @omeraplak , yeah I can do that. I think it's a bit more involved given how much everything changes, so i have to cherry pick changes across newer commits. I think it's worth deciding on the things brought up by @zrosenbauer first, that way i can rework the current version and then proceed to resolve conflicts and get it up to date with the latest commits. |
Thanks for taking the time to look through it @zrosenbauer 🚀
Can you explain your thought process for this, was it discussed anywhere or just the PR you linked? It aligns with
I agree with this, it's the default it makes sense. |
|
I'm not sure how accurate is this since since is a large codebase, I will give some tries later, but it would be nice if you guys could also review it: https://github.com/myrrakh/voltagent one thing inside core package.json I needed to set, it should have a script to change between workspace and latest for development The current errors on test: and @voltagent/google-ai: Failed to parse JSON response or validate against schema: SyntaxError: Expected property name or '}' in JSON at position 2 |
|
@alasano no matter what this is a huge change and you'll probably have a ton of conflicts if anyone edits the server anything... On
|
|
@alasano let me know if you need / want support on this. I might be able to take a stab at this over the weekend. |
|
I'm also available if you guys want an additional help |
- Rename packages/server-hono directory to packages/server - Update package name from @voltagent/server-hono to @voltagent/server - Update all imports and references across the codebase - Update deprecation messages to reference the new package name - Update test files and documentation references
|
I've started the pretty complicated process of getting this up to date with the main branch, however there's no real way to have this be free of merge conflicts at the end. Main is ~180 commits ahead of my branch, I've started a commit by commit process of cherry picking each commit ahead of my fork (a lot of them easily integrate since they don't touch the core package). For commits that made changes to core or the coupled server parts of core, the changes are being applied to the corresponding parts of core and decoupled server/server-adapter packages in my fork. I'll keep pushing progress in the branch here https://github.com/alasano/voltagent/tree/migration-integrator. I've got it set up so that it goes pretty fast, once I'm up to date with main I'll update my changes with feedback you guys have given. Even though it's fully backward compatible as discussed, it's still a big step to merge it after because you'll need to plan for it @omeraplak |
|
TY @alasano love it and yea Volt is moving lightening fast atm :) |
|
@alasano are you still working on this? so much has changed I think this pull would be hard to resolve/merge. @omeraplak if you're going to take this on possibly (or myself) we can probably close and just make sure we have a solid GitHub issue and put on roadmap |
|
Hey, |
|
No worries @omeraplak , I wasn't able to put enough time in to catch up with all the changes (voltagent moving too fast ;)). Looking forward to the official version of it. |
RFC: Server Decoupling Architecture - Introducing
createVoltServerAPITL;DR
Separates agent logic from server dependencies. If you only use agents directly, your bundle is now lighter.
If you need HTTP endpoints, install
@voltagent/server-honoand usecreateVoltServer({ agents: { agent } })instead ofnew VoltAgent({ agents: { agent } }).PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
Understanding VoltAgent's Role
VoltAgent has two distinct use cases that are often confused:
1. Using Agents Directly (No VoltAgent needed)
2. Exposing Agents via HTTP/WebSocket (VoltAgent's purpose)
Current Architecture Problems
Problem 1: Unnecessary Dependencies
@voltagent/coregives you:hono,ws,@hono/*packagesProblem 2: What Actually Happens
Problem 3: Technical Debt
AgentRegistry.getInstance()- global singleton patternserver/directory) mixed into core packageWhat is the new behavior?
Clear Separation of Concerns
1. Agent Usage Remains Unchanged
2. Server Functionality Moved to Separate Package
Key Differences Explained
BEFORE: Mixed Concerns
AFTER: Clear Separation
Technical Architecture Changes
Package Structure
@voltagent/core: Pure agent logic, zero server dependencies@voltagent/server-adapter: Framework-agnostic HTTP abstraction@voltagent/server-hono: Hono implementation of serverDependency Changes
// @voltagent/core/package.json dependencies: { - "@hono/node-server": "^1.14.0", - "@hono/node-ws": "^1.1.1", - "@hono/swagger-ui": "^0.5.1", - "@hono/zod-openapi": "^0.19.6", - "hono": "^4.7.7", - "ws": "^8.18.1", // ... only agent-related deps remain }Registry Pattern
AgentRegistry.getInstance()- global singletonLocalAgentRegistry- instance-based, no global stateRegistry Management
Migration Guide
If you only use agents (no HTTP endpoints)
No changes needed! Your code works exactly the same, just with a lighter bundle.
If you use VoltAgent for HTTP endpoints
Option 1: Keep existing code (deprecated)
Option 2: Migrate to new API
Benefits Summary
Implementation Notes
VoltAgentuses dynamic imports to maintain backward compatibility@voltagent/server-adapteris automatically installed with@voltagent/server-hono@voltagent/server-honoto just@voltagent/serverTBDFuture Work / Possibilities
Fixes #281