From bc32b7f42c07165c0da108aab70cb77e14695993 Mon Sep 17 00:00:00 2001 From: lxcong <83766787@qq.com> Date: Thu, 14 May 2026 17:15:14 +0800 Subject: [PATCH] fix(skill): align telemetry dispatch path and body field name with server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #31 wired the skill-side telemetry through two paths that don't connect, so zero usable events reached PostHog from a real LLM session: 1. SKILL.md instructed the LLM to call execute_tool(name="agentkey_internal", params={...}), but agentkey_internal is registered as a separate top-level MCP tool in @agentkey/mcp 0.3.10+ — not a route under execute_tool's router (which only knows agentkey_search / scrape / social / crypto). Calls returned "tool not found" and SKILL.md's silent-fallback swallowed the error. 2. The body wrapped properties under props: {...} but the server handler decodes Properties map[string]interface{} `json:"properties"`. Mismatched JSON tag → server saw a nil map and substituted an empty one, so the few events that did arrive had every business field stripped (only $lib/$os/$ip from posthog-go's auto-meta plus agent: "unknown" from NormalizeAgent("") survived). End-to-end isolation test confirmed that calling agentkey_internal directly with {event, properties: {...}} delivers all fields; the SKILL.md-prescribed shape {event, props: {...}} drops them all — sink, auth, dedupe all fine. Bug surface is exactly the two items above. Changes (skill-side only — 1.6.0 has no install base yet, easier to align skill with server than ship a breaking server change): - SKILL.md: all 6 dispatch sites use agentkey_internal({path, params}) directly instead of going through execute_tool. - SKILL.md: body field renamed props → properties to match the server handler's struct tag. No change to check-update.sh, MCP forwarder, or server. Existing 10 bats tests in tests/check-update.bats still pass — they cover the TELEMETRY-line emission, which is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- skills/agentkey/SKILL.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/skills/agentkey/SKILL.md b/skills/agentkey/SKILL.md index 8c3ec77..8d68956 100644 --- a/skills/agentkey/SKILL.md +++ b/skills/agentkey/SKILL.md @@ -48,9 +48,9 @@ The script may print **two kinds of lines** (in any order): - **Telemetry line** (zero or one): - `TELEMETRY ...` → forward via MCP, silently and best-effort: ``` - execute_tool(name="agentkey_internal", params={ + agentkey_internal({ path: "telemetry/event", - params: { event: "", props: { /* parsed key=value pairs */ } } + params: { event: "", properties: { /* parsed key=value pairs */ } } }) ``` - If the tool does not exist or fails, **ignore completely** — never surface a telemetry error to the user. @@ -86,9 +86,9 @@ If a Bash tool is available (Claude Code etc.), use `AskUserQuestion`. Otherwise After running **Step C**, dispatch (silently, ignore failures): ``` - execute_tool(name="agentkey_internal", params={ + agentkey_internal({ path: "telemetry/event", - params: { event: "upgrade_decision", props: { + params: { event: "upgrade_decision", properties: { from_version: "", to_version: "", choice: "accept_once" }} }) @@ -99,9 +99,9 @@ If a Bash tool is available (Claude Code etc.), use `AskUserQuestion`. Otherwise After the action, dispatch (silently, ignore failures): ``` - execute_tool(name="agentkey_internal", params={ + agentkey_internal({ path: "telemetry/event", - params: { event: "upgrade_decision", props: { + params: { event: "upgrade_decision", properties: { from_version: "", to_version: "", choice: "accept_always" }} }) @@ -127,9 +127,9 @@ If a Bash tool is available (Claude Code etc.), use `AskUserQuestion`. Otherwise Map the choice for telemetry: With-Bash uses `SNOOZED_LEVEL` (`1` → `snooze_1d`, `2` → `snooze_2d`, `3` → `snooze_7d`); No-Bash uses `snooze_1d` (no persisted level). Then dispatch (silently, ignore failures): ``` - execute_tool(name="agentkey_internal", params={ + agentkey_internal({ path: "telemetry/event", - params: { event: "upgrade_decision", props: { + params: { event: "upgrade_decision", properties: { from_version: "", to_version: "", choice: "" }} }) @@ -140,9 +140,9 @@ If a Bash tool is available (Claude Code etc.), use `AskUserQuestion`. Otherwise After the action, dispatch (silently, ignore failures): ``` - execute_tool(name="agentkey_internal", params={ + agentkey_internal({ path: "telemetry/event", - params: { event: "upgrade_decision", props: { + params: { event: "upgrade_decision", properties: { from_version: "", to_version: "", choice: "never_ask" }} }) @@ -166,9 +166,9 @@ On success: tell the user "✓ AgentKey updated to v\." On failure: show t After the `npx` command returns, dispatch (silently, ignore failures): ``` -execute_tool(name="agentkey_internal", params={ +agentkey_internal({ path: "telemetry/event", - params: { event: "upgrade_result", props: { + params: { event: "upgrade_result", properties: { from_version: "", to_version: "", status: <"ok" if npx succeeded else "fail">, error_class: