Skip to content

fix(local-agent): unify debug log tag across HTTP and report/sync lines#170

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
jeff-r2026:fix/local-agent-unify-log-tag
Jul 9, 2026
Merged

fix(local-agent): unify debug log tag across HTTP and report/sync lines#170
jeff-r2026 merged 1 commit into
Tencent:mainfrom
jeff-r2026:fix/local-agent-unify-log-tag

Conversation

@jeff-r2026

Copy link
Copy Markdown
Collaborator

Problem

The local-agent debug log mixed two tag formats within a single hook fire:

  • HTTP request/response lines (localAgentFetch): [local-agent 2bcf67] — has the local-agent prefix but no agent name, so an HTTP line couldn't be traced to which agent made it.
  • report / sync / command result lines: [2bcf67] [codebuddy] — has the agent name but no prefix.

Example (before):

[local-agent 2bcf67] → POST .../api/local-agent/sync
[local-agent 2bcf67] ← 200 OK POST .../api/local-agent/sync
[2bcf67] [codebuddy] sync OK (0 command(s))

Fix

  • Add a single localAgentTag(context) helper producing the unified [<id6>] [<tool>].
  • Change localAgentFetch / ackCommand to take the built tag (they previously took a bare agentId only to build the tag), so HTTP lines now carry the agent name too.
  • Converge all call sites (fetchUserGroups, processCommands, reportAndSyncLocalAgent) onto the helper.

No HTTP semantics or payloads changed — this is log-tag only.

After:

[2bcf67] [codebuddy] → POST .../api/local-agent/sync
[2bcf67] [codebuddy] ← 200 OK [OK] POST .../api/local-agent/sync
[2bcf67] [codebuddy] sync OK (0 command(s))

Test Plan

  • npx tsc --noEmit passes
  • npx vitest run src/__tests__/local-agent.test.ts — 12/12 pass
  • npm run build succeeds
  • End-to-end: triggered a real hook-dispatch stop --tool codebuddy against the live backend; all 13 debug.log lines now use the single [2bcf67] [codebuddy] format (verified the old [local-agent 2bcf67] shape is gone).

🤖 Generated with Claude Code

The local-agent debug log mixed two tag formats: HTTP request/response
lines used `[local-agent <id6>]` (prefix but no agent name) while
report/sync/command lines used `[<id6>] [<tool>]` (agent name but no
prefix). Same call, two shapes — and the HTTP lines couldn't be traced
to an agent.

Introduce a single `localAgentTag(context)` helper producing the unified
`[<id6>] [<tool>]`, and thread the built tag (instead of a bare agentId)
into localAgentFetch/ackCommand so every line — HTTP, report/sync, and
command ack — carries both the id and the agent name.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jeff-r2026 jeff-r2026 merged commit 1645ed0 into Tencent:main Jul 9, 2026
6 checks passed
@jeff-r2026 jeff-r2026 deleted the fix/local-agent-unify-log-tag branch July 9, 2026 05:32
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