Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(pi): match ToolDefinition.execute arity on 0.84.2

Alex Musichen109299f26296
diff --git a/src/cli/client_adapter.c b/src/cli/client_adapter.c
index 73cd9f112..cc7454793 100644
--- a/src/cli/client_adapter.c
+++ b/src/cli/client_adapter.c
@@ -153,6 +153,10 @@ char *cbm_client_adapter_pi(const char *binary_path) {
adapter_sb_t sb = {0};
emit_header(&sb, "pi");
+ /* Pin the coding-agent contract so a probe against @mariozechner/pi
+ * (pods CLI) or an old AgentTool arity cannot be mistaken for this file. */
+ sb_append(&sb, "// Target: @earendil-works/pi-coding-agent >= 0.74.0 (verified 0.84.2)\n"
+ "// ToolDefinition.execute(toolCallId, params, signal, onUpdate, ctx)\n");
sb_append(&sb, "import { spawn } from 'node:child_process';\n\n");
sb_append(&sb, "const BIN = '");
sb_append(&sb, bin);
@@ -218,11 +222,13 @@ char *cbm_client_adapter_pi(const char *binary_path) {
* literal; embedding it directly keeps the generated module free of a
* JSON.parse indirection and of any escaping drift. */
sb_append(&sb, schema ? schema : "{}");
- sb_append(&sb, ",\n execute: async (args, ctx) => {\n");
+ /* 0.84.2 calls execute(toolCallId, params, signal, onUpdate, ctx).
+ * The previous (args, ctx) shape bound the call id as the MCP args. */
+ sb_append(&sb, ",\n execute: async (toolCallId, params, signal, _onUpdate, ctx) => {\n");
sb_append(&sb, " const result = await call(");
sb_append_js_string(&sb, name);
sb_append(&sb,
- ", args, ctx?.signal);\n"
+ ", params, signal ?? ctx?.signal);\n"
" if (result && typeof result === 'object' && result.error) {\n"
" throw new Error(String(result.error));\n"
" }\n"
diff --git a/tests/test_agent_clients.c b/tests/test_agent_clients.c
index f15e69a66..89dda28ba 100644
--- a/tests/test_agent_clients.c
+++ b/tests/test_agent_clients.c
@@ -1122,7 +1122,11 @@ TEST(client_adapter_pi_default_exports_its_factory_issue1550) {
TEST(client_adapter_pi_emits_parameters_and_execute) {
char *js = cbm_client_adapter_pi("/usr/local/bin/codebase-memory-mcp");
ASSERT_NOT_NULL(js);
- ASSERT_NOT_NULL(strstr(js, "execute: async (args, ctx) => {"));
+ ASSERT_NOT_NULL(strstr(js, "execute: async (toolCallId, params, signal, _onUpdate, ctx) => {"));
+ ASSERT_NOT_NULL(strstr(js, ", params, signal ?? ctx?.signal)"));
+ ASSERT_NULL(strstr(js, "execute: async (args, ctx) => {"));
+ ASSERT_NULL(strstr(js, ", args, ctx?.signal)"));
+ ASSERT_NOT_NULL(strstr(js, "@earendil-works/pi-coding-agent"));
ASSERT_NOT_NULL(strstr(js, "result.content"));
ASSERT_NULL(strstr(js, "run: (args, ctx)"));
ASSERT_NOT_NULL(strstr(js, "parameters:"));