pi-mono/packages
Petr Houška 6d3e342b25
fix(coding-agent): follow local schema refs in tool search and codemode summaries (#11850)
Fixes #11803.

**Problem**

`tool_search` builds a tool's search text from its parameter schema but
never followed `$ref`. MCP servers (Pydantic, FastMCP) often put nested
models in `$defs`:

```json
{ "properties": { "options": { "$ref": "#/$defs/options" } },
  "$defs": { "options": { "properties": { "mode": { "description": "reconciliation" } } } } }
```

Search text was `Inspect records options`, so
`tool_search("reconciliation")` found nothing. Durable's copy of
`tool_search` had the same gap. The codemode `resolves to` summary had
the same blind spot for output schemas: a field behind a `$ref` showed
as `structuredContent?` with no field names.

**Fix**

- pi-codemode exports its existing local JSON Pointer resolver as
`resolveSchemaRef(ref, root)`. A malformed percent escape now resolves
to nothing instead of throwing `URIError` (this also affected
`schemaToType()`).
- coding-agent and Durable `schemaText()` follow local `$ref`s. Each
referenced subschema is read once, so recursive and shared definitions
neither loop nor inflate BM25 term counts. Unreferenced `$defs` and
remote refs stay out.
- coding-agent `describeFields()`/`describeUnionFields()` resolve `$ref`
chains against the output schema root.

**Tests**

- `packages/codemode/test/declarations.test.ts`: escaped, remote,
missing, malformed refs.
- `packages/coding-agent/test/tool-search.test.ts`: refs, escaped
segments, recursion and shared definitions, unused definitions.
- `packages/coding-agent/test/suite/agent-session-codemode.test.ts`:
summary through root, field, const, and union refs.
- `packages/durable/test/tool-search.test.ts`: end-to-end load via a
ref'd description; unused definition does not match.

`npm run check` passes.
2026-11-06 00:19:58 +01:00
..
agent Anthropic message threads (#11545) 2026-11-03 14:07:57 +01:00
ai fix(ai,coding-agent): remove "(legacy)" marker from OpenAI Codex provider name 2026-11-05 22:51:36 +01:00
chord feat(p2): Chord v2 cleanup pass 2026-11-05 18:22:13 +00:00
codemode fix(coding-agent): follow local schema refs in tool search and codemode summaries (#11850) 2026-11-06 00:19:58 +01:00
coding-agent fix(coding-agent): follow local schema refs in tool search and codemode summaries (#11850) 2026-11-06 00:19:58 +01:00
durable fix(coding-agent): follow local schema refs in tool search and codemode summaries (#11850) 2026-11-06 00:19:58 +01:00
env fix(env): kill what a process program left running when it exits 2026-11-03 14:17:21 +01:00
evals Release v1.5.0 2026-11-02 11:38:21 +01:00
mcp docs(coding-agent): changelog for MCP OAuth callback close hang 2026-11-05 23:57:00 +01:00
schema fix(schema): num no longer takes nan and infinity 2026-11-05 14:20:32 +01:00
telemetry feat(chord): telemetry from pages and workers stored by the server, who a span was for 2026-11-04 11:59:14 +00:00
tui fix(tui): prevent cursor marker leaks (#9441) 2026-11-04 11:26:48 +01:00