-
Notifications
You must be signed in to change notification settings - Fork 148
feat(obs): basic agent instrumentation #238
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: 25db268 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 |
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.
Pull Request Overview
This PR introduces basic observability instrumentation for Agents by adding an observability property that emits events during key operations.
- Adds an Observability interface and default implementation (genericObservability) in a new observability module.
- Integrates observability events into various Agent lifecycle methods (RPC calls, state updates, schedule events, connection, and destruction).
- Updates the build script and augments AIChatAgent with chat message instrumentation.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
packages/agents/src/observability/index.ts | Introduces the observability type definitions and default logger. |
packages/agents/src/index.ts | Integrates observability event emission throughout Agent methods. |
packages/agents/src/ai-chat-agent.ts | Adds chat message instrumentation and filters duplicate messages. |
packages/agents/scripts/build.ts | Includes the observability module in the build process. |
Files not reviewed (1)
- packages/agents/package.json: Language not supported
Comments suppressed due to low confidence (1)
packages/agents/src/ai-chat-agent.ts:241
- [nitpick] Consider renaming '#messagesNotAlreadyInAgent' to a more descriptive name like '#filterNewMessages' to improve clarity.
#messagesNotAlreadyInAgent(messages: ChatMessage[]) {
return; | ||
} | ||
|
||
console.log(event); |
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.
I'm not sure if we should keep this log as the default for non-local mode, there could be billing implications if the user has Workers Logs enabled ($0.30 per million logs) @threepointone what do you think?
Adds a new `observability` property to Agents that receives events during the Agent's exeuction that can be used for whatever. The default observability implementation prints the events to console, but in the future this could be hooked up to a UI or some other observability tooling.
fc015af
to
25db268
Compare
Adds a new
observability
property to Agents that receives events during the Agent's exeuction that can be used for configurable observability. The default observability implementation prints the events to console, but in the future this could be hooked up to a UI or some other observability tooling.