agents icon indicating copy to clipboard operation
agents copied to clipboard

Adds event observability and admin capabilities

Open flenter opened this issue 1 year ago • 3 comments

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:

    1. 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 getAgentEventStream function
    2. 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).
    3. Added a secret method 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)
    4. Added a listMcpConnections method so connection information is serializable/compatible with RPC

flenter avatar May 01 '25 16:05 flenter

🦋 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

changeset-bot[bot] avatar May 01 '25 16:05 changeset-bot[bot]

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?

threepointone avatar May 01 '25 19:05 threepointone

Sounds good. Let's do that.

flenter avatar May 02 '25 07:05 flenter