Skip to content

Commit d270b12

Browse files
authored
fix(coding-agents): report and attribute the configured MCP harness (#3342)
The MCP server resolved its harness (HINDSIGHT_MCP_HARNESS, defaulting to claude-code) for bank resolution but never passed it to buildKnowledgeTools, so the tools it builds had no idea which agent they were serving. Two things follow from passing it: - hindsight_diagnose reports the actual harness instead of 'unknown'. - hindsight_ingest_document now stamps the harness:<id> tag and metadata.harness. Documents ingested through the MCP tool were previously unattributed, and the documents list resolves a document's agent logo and filter from exactly those fields. cfg.harness is the right source: loadConfig back-fills the asking harness onto an unset field (#3247), so it is the launching harness rather than resolveConfig's 'opencode' default. Co-authored-by: TheAngryPit
1 parent 056982b commit d270b12

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

hindsight-integrations/coding-agents/src/mcp-server.test.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, expect, it, vi } from "vitest";
22
import { selectTools } from "./mcp-server";
33
import { resolveConfig } from "./core/config";
44
import type { HindsightClient } from "./core/hindsight";
@@ -29,4 +29,29 @@ describe("selectTools", () => {
2929
].sort()
3030
);
3131
});
32+
33+
it("propagates the configured harness to diagnostics", async () => {
34+
const cfg = resolveConfig({ harness: "codex" });
35+
const tools = selectTools(cfg, stubClient, "b");
36+
const diagnose = tools.find((tool) => tool.name === "hindsight_diagnose");
37+
38+
expect(diagnose).toBeDefined();
39+
const result = await diagnose!.handler({});
40+
expect(JSON.parse(result.content[0].text)).toMatchObject({ harness: "codex" });
41+
});
42+
43+
it("also attributes documents ingested through the MCP tool to that harness", async () => {
44+
// The same option feeds hindsight_ingest_document, which until now stamped nothing: the
45+
// documents list resolves a document's agent logo from `metadata.harness` / `harness:<id>`,
46+
// so MCP-ingested documents used to show up unattributed.
47+
const retain = vi.fn().mockResolvedValue(undefined);
48+
const client = { retain } as unknown as HindsightClient;
49+
const tools = selectTools(resolveConfig({ harness: "codex" }), client, "b");
50+
const ingest = tools.find((tool) => tool.name === "hindsight_ingest_document");
51+
52+
await ingest!.handler({ title: "Runbook", content: "steps" });
53+
const [, , , tags, , opts] = retain.mock.calls[0];
54+
expect(tags).toContain("harness:codex");
55+
expect(opts.metadata).toMatchObject({ harness: "codex" });
56+
});
3257
});

hindsight-integrations/coding-agents/src/mcp-server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import { buildKnowledgeTools, type ToolSpec } from "./core/knowledge-tools";
2323
* connects, it just has nothing registered.
2424
*/
2525
export function selectTools(cfg: Config, client: HindsightClient, bankId: string): ToolSpec[] {
26-
return cfg.disabled ? [] : buildKnowledgeTools(client, bankId, { repoDir: process.cwd() });
26+
return cfg.disabled
27+
? []
28+
: buildKnowledgeTools(client, bankId, { repoDir: process.cwd(), harness: cfg.harness });
2729
}
2830

2931
async function main() {

0 commit comments

Comments
 (0)