Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

zebp
Copy link
Collaborator

@zebp zebp commented Apr 30, 2025

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.

@zebp zebp requested review from threepointone and Copilot April 30, 2025 19:08
Copy link

changeset-bot bot commented Apr 30, 2025

🦋 Changeset detected

Latest commit: 25db268

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

Copy link
Contributor

@Copilot Copilot AI left a 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);
Copy link
Collaborator Author

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant