Skip to content

docs: surface response contracts per tool in docs/llms.txt#761

Closed
bokelley wants to merge 1 commit into
mainfrom
docs-response-contracts-in-llms
Closed

docs: surface response contracts per tool in docs/llms.txt#761
bokelley wants to merge 1 commit into
mainfrom
docs-response-contracts-in-llms

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Extends the existing `generate-agent-docs` generator so each tool section in `docs/llms.txt` emits a Response (success branch) block with required + optional fields, mirroring the existing request block. Pulled straight from the bundled JSON schemas — no new source of truth.

Example (build_creative)

Before (request only):

```

`build_creative`

Request parameters for AI-powered creative generation.

Required: `idempotency_key: string`
Optional: `message`, `creative_manifest`, `creative_id`, ...
```

After (request + response):

```

`build_creative`

Request parameters for AI-powered creative generation.

Request:

  • Required: `idempotency_key: string`
  • Optional: `message`, `creative_manifest`, `creative_id`, ...

Response (success branch):

  • Required: `creative_manifest: Creative Manifest`
  • Optional: `sandbox: boolean`, `expires_at: string`, `preview: object`, `context: Context`
    ```

Why

Matrix runs kept surfacing the same drift pattern: agents dropped required response fields — missing `format_id` on `creative_manifest`, plural-variant hallucinations (`creative_deliveries` → `creatives`), missing top-level `currency` — because the skill prose documented the intent but the full per-field contract lived in the generated schemas and was never indexed in the llms.txt file Claude actually reads when building an agent.

With this, the contract is one anchored section away (`docs/llms.txt#build_creative`), and skills can lean on pointer references instead of embedding the contract inline.

Test plan

  • `npm run generate-agent-docs` runs clean, regens `docs/llms.txt` with Response sections
  • `npm run typecheck` clean
  • Spot-checked 5 tools (build_creative, get_creative_delivery, create_property_list, sync_catalogs, check_governance) — response contracts match schema
  • Existing CI docs-sync check still passes

Follow-ups (separate PRs)

  • Slim each skill's inline tool contracts down to one-line pointers into `docs/llms.txt#`. Smaller skill files, no duplication.
  • Optionally surface `outputSchema` on MCP tool definitions so any MCP client can introspect response contracts without reading llms.txt.

Each tool section now emits a "Response (success branch)" block with the
required + optional fields, mirroring the existing request block. Pulled
straight from the bundled JSON schemas; zero new source of truth.

Closes the drift path matrix runs kept surfacing — agents dropped
required response fields (missing format_id on creative_manifest, plural
hallucinations like creative_deliveries for creatives, missing top-level
currency) because the skill prose documented intent but the full
per-field contract lived in the generated schemas and was never indexed
in the llms.txt file Claude actually reads.

Anchored sections let skills point at docs/llms.txt#<tool> instead of
embedding the contract inline — keeps skills lean.
bokelley added a commit that referenced this pull request Apr 22, 2026
…slim on creative-agent (#762)

* docs: surface response contracts per tool in docs/llms.txt

Each tool section now emits a "Response (success branch)" block with the
required + optional fields, mirroring the existing request block. Pulled
straight from the bundled JSON schemas; zero new source of truth.

Closes the drift path matrix runs kept surfacing — agents dropped
required response fields (missing format_id on creative_manifest, plural
hallucinations like creative_deliveries for creatives, missing top-level
currency) because the skill prose documented intent but the full
per-field contract lived in the generated schemas and was never indexed
in the llms.txt file Claude actually reads.

Anchored sections let skills point at docs/llms.txt#<tool> instead of
embedding the contract inline — keeps skills lean.

* docs(skills): point at llms.txt for field contracts; slim creative-agent

Every build-*-agent skill's "Tools and Required Response Shapes"
section now opens with a canonical-contracts pointer directing Claude
at the anchored llms.txt section for per-tool request + response
fields — one source of truth, refreshed on every schema sync.

build-creative-agent gets a surgical slim: the verbose response-shape
blocks (which duplicate llms.txt verbatim now that #761 landed) are
collapsed into a compact handler-binding table. Gotchas and anti-
patterns stay; field enumerations move to llms.txt. Net -94 lines,
same signal. The other 7 skills get the pointer line only — follow-up
passes can do per-skill surgical slims once the pattern is validated.

With strict response validation default in dev (#727/#757), drift
between a skill example and the schema now fails immediately at the
call site with the exact field path. The skill's job is to document
patterns/gotchas; the schema's job is to enforce shape. This
separation was muddied when every skill tried to re-state the shape
inline.

* docs(skills): imperative callout + anchor column per expert review

Experts flagged the passive "contracts live at X" wording — Claude
doesn't follow pointers without an imperative trigger. Rewrote to lead
with "Before writing any handler's return statement, fetch
docs/llms.txt and grep for #### \`<tool_name>\`" and reframed the
validation safety-net from threat to permission. Applied to all 8
skills.

Added a per-row Contract column to the creative-agent handler-binding
table with direct anchor links — more reliably followed than a general
pointer three lines up.

Regenerated schemas/types (upstream context-object shift) and widened
si-session-manager.ts generateInitialResponse signature from string to
unknown so the overrides accept the new ContextObject shape. Unblocks
CI's Validate generated files check.
@github-actions github-actions Bot mentioned this pull request Apr 22, 2026
@bokelley

Copy link
Copy Markdown
Contributor Author

Closing as superseded.

PR #762 (merged 2026-04-22T02:55Z) already landed this change — docs/llms.txt on current main emits **Response (success branch):** blocks for every tool section (51 occurrences), and scripts/generate-agent-docs.ts was updated to produce them. PR #762's skill-slim commits lean on those anchors exactly as the follow-up plan in this PR's body described.

Net delta of this branch vs current main is a timestamp shuffle; no remaining code value.

@bokelley bokelley closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant