Skip to content

fix(local-agent): derive local_agent_id from per-tool install dir, not teamai home#173

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
jeff-r2026:fix/local-agent-id-install-dir
Jul 9, 2026
Merged

fix(local-agent): derive local_agent_id from per-tool install dir, not teamai home#173
jeff-r2026 merged 1 commit into
Tencent:mainfrom
jeff-r2026:fix/local-agent-id-install-dir

Conversation

@jeff-r2026

Copy link
Copy Markdown
Collaborator

Problem

The HTTP local-agent path seeds deriveLocalAgentId() with getLocalAgentHome() (~/.teamai/local-agent) — the same install_path for every tool. The historical status-report path instead used the tool's own dir (~/.codebuddy, ~/.claude, from toolPaths skills dirname).

Since install_path feeds the id hash, a machine upgrading from the status-report era saw its local_agent_id change, so the backend counted one agent as two.

Measured on one machine (codebuddy):

  • status-report era (0.17.2): 370e8ec0bf05fd60
  • current HTTP local-agent: 101a235cb52bcf67

Fix

The algorithm is unchanged (machine-id.ts untouched). Only the install_path input is realigned to the per-tool dir:

  • New resolveAgentInstallPath(agentType) returns ~/<dirname(toolPaths[tool].skills)> (e.g. .codebuddy/skills~/.codebuddy), reusing the same toolPaths map buildReportPayload already uses. Unknown tools fall back to ~/.<tool>.
  • resolveLocalAgentId uses it instead of getLocalAgentHome().
  • TEAMAI_LOCAL_AGENT_ID override preserved.

Result: upgraded ids match the status-report era byte-for-byte, and different tools still get distinct ids (both agent_type and the per-tool dir feed the hash).

Migration note

This changes the id once more for users already on the drifted (~/.teamai/local-agent) build, bringing them back in line with the larger status-report-era population. One-time realignment, by design.

Test Plan

  • npx tsc --noEmit — passes
  • npx vitest run src/__tests__/local-agent.test.ts src/__tests__/machine-id.test.ts — 23 passed (incl. 3 new: per-tool口径, claude≠codebuddy, env override)
  • End-to-end (teamai init --http + codebuddy -p test, real backend):
    • codebuddy local_agent_id == 370e8ec0bf05fd60 (matches 0.17.2) ✅
    • claude local_agent_id == 8d8d13e2321c9482, and ≠ codebuddy ✅
    • backend receipts: local-codebuddy-05fd60, local-claude-1c9482

🤖 Generated with Claude Code

…t teamai home

The HTTP local-agent path seeded deriveLocalAgentId() with getLocalAgentHome()
(~/.teamai/local-agent) — the same install_path for every tool. The historical
status-report path instead used the tool's own dir (~/.codebuddy, ~/.claude,
derived from toolPaths' skills dirname). Since install_path feeds the id hash,
a machine upgrading from the status-report era saw its local_agent_id change
(e.g. codebuddy 370e8ec0bf05fd60 → 101a235cb52bcf67), so the backend counted
one agent as two.

The algorithm is unchanged. Only the install_path input is realigned to the
per-tool dir via a new resolveAgentInstallPath() that reuses the same toolPaths
map buildReportPayload already uses; unknown tools fall back to ~/.<tool>.
Result: upgraded ids match the status-report era byte-for-byte, and different
tools still get distinct ids (agent_type + per-tool dir both feed the hash).

Verified end-to-end (init --http + codebuddy hook): codebuddy id ==
370e8ec0bf05fd60 (matches 0.17.2), claude id == 8d8d13e2321c9482, and the two
differ.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jeff-r2026 jeff-r2026 merged commit ed2a74d into Tencent:main Jul 9, 2026
6 checks passed
@jeff-r2026 jeff-r2026 deleted the fix/local-agent-id-install-dir branch July 9, 2026 08:00
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