Skip to content

Move token usage calculation into agent logic#91

Merged
Soph merged 7 commits intomainfrom
soph/token-usage-to-agent
Jan 23, 2026
Merged

Move token usage calculation into agent logic#91
Soph merged 7 commits intomainfrom
soph/token-usage-to-agent

Conversation

@Soph
Copy link
Collaborator

@Soph Soph commented Jan 22, 2026

  • Moved the token calculation into agent specific implementations.
  • made AgentType and AgentType proper types

@Soph Soph requested a review from a team as a code owner January 22, 2026 17:50
@Soph Soph force-pushed the soph/chunking branch 2 times, most recently from 64b4763 to 7a2c191 Compare January 22, 2026 20:01
@Soph Soph force-pushed the soph/token-usage-to-agent branch 2 times, most recently from c1a2897 to 212fd23 Compare January 22, 2026 20:20
Copilot AI review requested due to automatic review settings January 23, 2026 03:02
Copy link
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@khaong
Copy link
Contributor

khaong commented Jan 23, 2026

TODO from #90: Add Type() string method to the Agent interface that returns the display name (e.g., "Claude Code", "Gemini CLI").

This will provide an explicit mapping between registry names (Name()) and display names (Type()) at the agent level, replacing the hardcoded AgentTypeToRegistryName map.

Context: #90 added an interim fix where GetByAgentType accepts both formats, but the proper solution is for each agent to own its display name via a Type() method.

Base automatically changed from soph/chunking to main January 23, 2026 04:02
@khaong khaong self-assigned this Jan 23, 2026
Soph added 2 commits January 23, 2026 15:04
Entire-Checkpoint: 9c0fb663da40
Entire-Checkpoint: d6da3f10e6fe
Copy link
Contributor

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Add Type() to Agent interface to expose the agent type identifier
(e.g., "Claude Code", "Gemini CLI") that's stored in metadata and
trailers. This provides a clean way to get the type identifier from
an agent instance.

- Name() returns the registry key (e.g., "claude-code", "gemini")
- Type() returns the type identifier (e.g., "Claude Code", "Gemini CLI")

Also updates GetByAgentType to accept both type identifiers and
registry keys for flexibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Entire-Checkpoint: 720c20f08988
@khaong khaong force-pushed the soph/token-usage-to-agent branch from 97fdd24 to 52b3d55 Compare January 23, 2026 04:38
Copilot AI review requested due to automatic review settings January 23, 2026 04:38
Copy link
Contributor

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

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

@khaong
Copy link
Contributor

khaong commented Jan 23, 2026

Done in commit 52b3d55 - added Type() method to Agent interface, implemented by both claude and gemini agents. The hardcoded AgentTypeToRegistryName map has been removed; GetByAgentType now dynamically searches agents by their Type() method.

Introduces compile-time type safety for agent identifiers:
- AgentName: registry keys (e.g., "claude-code", "gemini")
- AgentType: display names stored in metadata (e.g., "Claude Code")

This distinguishes between the two identifier forms and prevents
accidental misuse throughout the codebase.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Entire-Checkpoint: cd742eb8d913
Copy link
Contributor

@khaong khaong left a comment

Choose a reason for hiding this comment

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

I added the AgentType and AgentName as types so we have a little bit of type safety going forwards

Soph added 3 commits January 23, 2026 11:08
Entire-Checkpoint: 6af107c86703
Copilot AI review requested due to automatic review settings January 23, 2026 10:09
Copy link
Contributor

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

Copilot reviewed 38 out of 38 changed files in this pull request and generated no new comments.

@Soph Soph merged commit ecbd5b6 into main Jan 23, 2026
9 checks passed
@Soph Soph deleted the soph/token-usage-to-agent branch January 23, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants