Adds event observability and admin capabilities
Agents manage a lot of state and emit many events that are important to monitor during development and in production.
While working on @fiberplane/agents, we’ve instrumented the Agent class using a mixin (previously a decorator). We’ve realized this should be built into the framework and made easily pluggable.
This PR overlaps with #238 — we should likely merge or coordinate the two.
In addition to what’s in #238, this PR:
-
Records slightly different set of events (including request and outgoing events like: response and broadcast/websocket send events).
-
Proposes the following changes to the framework:
- Admin route inside the worker to expose events stream. This enables embedded interfaces (like Django or Elixir LiveView) to be built on top for debugging or development workflows. This is exposed as an SSE stream and can be accessed via the
getAgentEventStreamfunction - Added a property on the Agent that accepts an array of
EventObservers(which is similar to what is proposed in #238 but allows for multiple event observers). - Added a
secretmethod that returns a random string, to make guessing of the uri for events harder, though i don't think this uri should be accessible (this is also only an issue if the agent is exposed to incoming traffic from the internet) - Added a listMcpConnections method so connection information is serializable/compatible with RPC
- Admin route inside the worker to expose events stream. This enables embedded interfaces (like Django or Elixir LiveView) to be built on top for debugging or development workflows. This is exposed as an SSE stream and can be accessed via the
🦋 Changeset detected
Latest commit: e61aef9b6f32aebde2c3794f77114a342b03360e
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 2 packages
| Name | Type |
|---|---|
| agents | Patch |
| hono-agents | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Thanks so much for this PR, it looks great. I'd love to figure out a way to make this work for bout fiberplane as well as our future plans.
I'm on a flight tomorrow all day so can only get to this over the weekend/early next week, let's revisit it then?
Sounds good. Let's do that.