ktx/packages/llm/src
Andrey Avtomonov 49f1e2720e
fix(llm): wire prompt caching through all Anthropic call sites (#90)
* fix(llm): wire prompt caching through all Anthropic call sites

- page-triage classifier + light-extraction now put the static skill
  prompt in `system:` so the per-document caches hit instead of
  re-sending boilerplate in the user message every call.
- Description generation builders return `{ system, user }` with
  instruction text + word limit moved into the cacheable system.
- Relationship-LLM proposal framing moved to `system:`.
- `KtxMessageBuilder.wrapSimple` skips the history breakpoint for
  single-message calls (cache write that could never be reused).
- Gateway backend now sets `anthropic-beta: extended-cache-ttl-2025-04-11`
  so 1h TTLs don't silently downgrade to 5m on Gateway routes.

* fix(llm): keep wrapSimple history breakpoint so multi-step agent loops cache

Reverts the wrapSimple `messages.length > 1` guard from the prior commit.
agent-runner uses wrapSimple with a single user message, but generateText
runs a multi-step tool loop inside it — the cache marker on the first user
message is reused by every subsequent step, so it isn't waste.
The release validator (scripts/validate-llm-debug-jsonl.mjs) also requires
a `message-part` marker target in captured debug JSONL.
2026-05-14 15:36:27 +02:00
..
embedding-health.test.ts ci: run pre-commit checks in CI (#74) 2026-05-13 19:49:25 +02:00
embedding-health.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
embedding-provider.test.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
embedding-provider.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
index.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
message-builder.test.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
message-builder.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
model-health.test.ts ci: run pre-commit checks in CI (#74) 2026-05-13 19:49:25 +02:00
model-health.ts feat(llm): add local AI SDK DevTools tracing 2026-05-12 11:13:14 +02:00
model-provider.test.ts fix(llm): wire prompt caching through all Anthropic call sites (#90) 2026-05-14 15:36:27 +02:00
model-provider.ts fix(llm): wire prompt caching through all Anthropic call sites (#90) 2026-05-14 15:36:27 +02:00
package-exports.test.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
repair.test.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
repair.ts rename klo to ktx 2026-05-10 23:51:24 +02:00
types.ts rename klo to ktx 2026-05-10 23:51:24 +02:00