Skip to content

refactor(agents): simplify mergeTelemetry implementation#76

Merged
zrosenbauer merged 1 commit intomainfrom
refactor/agents-telemetry-cleanup
Apr 2, 2026
Merged

refactor(agents): simplify mergeTelemetry implementation#76
zrosenbauer merged 1 commit intomainfrom
refactor/agents-telemetry-cleanup

Conversation

@zrosenbauer
Copy link
Copy Markdown
Member

Summary

  • Extract the "funkai.agentChain" magic string into an AGENT_CHAIN_METADATA_KEY constant for clarity and single-source-of-truth
  • Replace mutable merged variable + isNil guard with a direct return using nullish coalescing (??) for functionId
  • Net reduction of 2 lines; no behavioral change

Test plan

  • pnpm typecheck --filter=@funkai/agents passes
  • pnpm test --filter=@funkai/agents — all 665 tests pass

…acted constant

Extract magic string "funkai.agentChain" into an AGENT_CHAIN_METADATA_KEY
constant and replace the mutable merged variable + isNil guard with a
single return expression using nullish coalescing for functionId.

Co-Authored-By: Claude <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: a11fd3f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
funkai Ready Ready Preview, Comment Apr 2, 2026 10:20pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

Added a changeset configuration file and refactored the resolveTelemetry function to compute the merged telemetry object directly, set functionId via nullish-coalescing, and replace the string literal metadata key "funkai.agentChain" with a named constant while preserving existing control flow.

Changes

Cohort / File(s) Summary
Changeset Configuration
.changeset/telemetry-cleanup.md
New changeset file with YAML frontmatter markers only.
Telemetry Refactoring
packages/agents/src/core/agents/base/telemetry.ts
Refactored resolveTelemetry to compute merged telemetry directly, use nullish-coalescing for functionId assignment, and replace string literal "funkai.agentChain" with AGENT_CHAIN_METADATA_KEY constant. Control flow and ancestry serialization format unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • #65 — Agent telemetry handling with functionId and agent-chain metadata management
  • #75 — Direct continuation refactoring the same resolveTelemetry implementation with nullish-coalescing and constant-based metadata key
  • #50 — Introduction and propagation of agentChain ancestry data in telemetry
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring in the changeset: simplifying the mergeTelemetry (or resolveTelemetry) implementation through code restructuring.
Description check ✅ Passed The description is directly related to the changeset, detailing the specific refactoring changes made: extracting a magic string constant, replacing mutable variables with nullish coalescing, and confirming test coverage.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/agents/src/core/agents/base/telemetry.ts`:
- Around line 6-7: The JSDoc for the AGENT_CHAIN_METADATA_KEY constant is
currently a single-line block causing the jsdoc-js(multiline-blocks) warning;
update the comment above AGENT_CHAIN_METADATA_KEY to a multiline JSDoc block by
expanding it into the standard /* * ... */ multi-line form (i.e., start /** on
its own line, put the description on the next line prefixed with *, and close */
on its own line) so the symbol AGENT_CHAIN_METADATA_KEY in telemetry.ts uses a
multiline JSDoc comment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4de21fe8-092a-422d-add3-0437ee75d560

📥 Commits

Reviewing files that changed from the base of the PR and between 4913e73 and a11fd3f.

📒 Files selected for processing (2)
  • .changeset/telemetry-cleanup.md
  • packages/agents/src/core/agents/base/telemetry.ts

@zrosenbauer zrosenbauer merged commit 4ffbed5 into main Apr 2, 2026
5 checks passed
@zrosenbauer zrosenbauer deleted the refactor/agents-telemetry-cleanup branch April 2, 2026 22:39
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