fix(local-agent): derive local_agent_id from per-tool install dir, not teamai home#173
Merged
jeff-r2026 merged 1 commit intoJul 9, 2026
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The HTTP local-agent path seeds
deriveLocalAgentId()withgetLocalAgentHome()(~/.teamai/local-agent) — the sameinstall_pathfor every tool. The historical status-report path instead used the tool's own dir (~/.codebuddy,~/.claude, fromtoolPathsskills dirname).Since
install_pathfeeds the id hash, a machine upgrading from the status-report era saw itslocal_agent_idchange, so the backend counted one agent as two.Measured on one machine (codebuddy):
370e8ec0bf05fd60101a235cb52bcf67Fix
The algorithm is unchanged (
machine-id.tsuntouched). Only theinstall_pathinput is realigned to the per-tool dir:resolveAgentInstallPath(agentType)returns~/<dirname(toolPaths[tool].skills)>(e.g..codebuddy/skills→~/.codebuddy), reusing the sametoolPathsmapbuildReportPayloadalready uses. Unknown tools fall back to~/.<tool>.resolveLocalAgentIduses it instead ofgetLocalAgentHome().TEAMAI_LOCAL_AGENT_IDoverride preserved.Result: upgraded ids match the status-report era byte-for-byte, and different tools still get distinct ids (both
agent_typeand 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— passesnpx 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)teamai init --http+codebuddy -p test, real backend):local_agent_id==370e8ec0bf05fd60(matches 0.17.2) ✅local_agent_id==8d8d13e2321c9482, and ≠ codebuddy ✅local-codebuddy-05fd60,local-claude-1c9482🤖 Generated with Claude Code