-
Notifications
You must be signed in to change notification settings - Fork 148
Adds event observability and admin capabilities #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: e61aef9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR has several issues that needs to be fixed.
- code duplication - In
utils.ts
,createResponsePayload
andcreateRequestPayload
share 90% identical code, extract the stream reading logic.
2.Unbounded memory usage - using standard stream readers in a CF Workers env has memory limits (ig around ~128MB). Unbounded stream reading can't be good here, i suggest to add stream size limits (~10MB) also chunk for large payloads
-
dependency choice - why a separate event library is needed when CF workers support standard browser
EventTarget
. -
security for AI agent admin route - For agent monitoring, a simple "secret" might not be enough, try to add proper worker authentication patterns like api tokens or JWTs.
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:
getAgentEventStream
functionEventObservers
(which is similar to what is proposed in feat(obs): basic agent instrumentation #238 but allows for multiple event observers).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)