pi-mono/packages/coding-agent/test/suite
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
..
regressions fix(coding-agent): wait for a started OAuth refresh to be saved before exit (#11812) 2026-11-05 00:32:41 +01:00
agent-session-bash-persistence.test.ts fix(coding-agent): strip ANSI sequences split across user bash output chunks 2026-10-07 15:02:59 +02:00
agent-session-boundaries.test.ts feat(tui,coding-agent): report program status via OSC 7501 2026-10-07 19:05:41 +00:00
agent-session-codemode.test.ts fix(coding-agent): follow local schema refs in tool search and codemode summaries (#11850) 2026-11-06 00:19:58 +01:00
agent-session-compaction-model-overrides.test.ts fix(coding-agent): remove fixed output limits from summary requests (#11036) 2026-10-16 13:53:16 +02:00
agent-session-compaction.test.ts feat(coding-agent): Virtual models (#10035) 2026-09-28 23:30:45 +02:00
agent-session-mcp-oauth.test.ts fix(coding-agent): cancel MCP OAuth sign-ins and stop refreshing on close 2026-10-07 16:18:46 +02:00
agent-session-mcp.test.ts feat(mcp): shared tool naming, schema, output limit and config helpers 2026-11-03 14:17:21 +01:00
agent-session-model-extension.test.ts fix(coding-agent): cycle to the only model in scope when the active model is outside it (#11832) 2026-11-05 10:39:18 +01:00
agent-session-prompt.test.ts fix(coding-agent): emit before_agent_start for runs started by custom messages (#10739) 2026-10-12 09:53:24 +02:00
agent-session-queue.test.ts fix(coding-agent): fix CI type check and image-only steering test 2026-11-04 10:34:45 +00:00
agent-session-retry-events.test.ts fix(coding-agent): close compaction cancellation races 2026-09-19 19:18:18 +02:00
agent-session-runtime.test.ts fix(coding-agent): save new session file at the first user message 2026-09-25 16:27:51 +02:00
agent-session-tool-orchestration.test.ts feat(coding-agent): codemode and MCP 2026-09-29 09:12:50 +02:00
agent-session-tool-result-images.test.ts feat(ai,coding-agent): add image input limits (closes #9631) 2026-09-20 22:59:16 +02:00
harness.ts fix(ai): recover from Copilot request-size overflow 2026-10-19 22:46:26 +02:00
lax-message-content.test.ts fix(ai,agent,coding-agent): normalize null message content at ingestion boundaries (#6343) 2026-07-06 20:47:08 +02:00
mcp-oauth-server.ts fix(coding-agent): send provider tokens in pi mcp list 2026-11-04 17:59:41 +01:00
README.md docs(coding-agent): remove issue-specific regression test placement rule (#8775) 2026-08-28 16:39:28 +02:00
virtual-models.test.ts fix(coding-agent): remove fixed output limits from summary requests (#11036) 2026-10-16 13:53:16 +02:00

Coding agent suite tests

Use test/suite/ for the new harness-based test suite around AgentSession and AgentSessionRuntime.

Rules:

  • Use test/suite/harness.ts
  • Use the faux provider from packages/ai/src/providers/faux.ts
  • Do not use real provider APIs, real API keys, network calls, or paid tokens
  • Keep these tests CI-safe and deterministic
  • Do not use or extend the legacy test/test-harness.ts path unless a missing capability forces it