Skip to content

Cache model responses and survive partial failures #9

Description

@tabkram

Why

src/llm.ts:106 is a single generateText call with no caching. Two consequences:

  1. Regenerating an unchanged range costs full price. During template or config work you re-run the same range repeatedly and pay every time.
  2. Partial failures may discard completed work. A multi-language or multi-release run makes several sequential model calls. If the last one fails, it needs confirming that the successful ones are not lost — that is real money and a bad CI experience.

Scope

Response cache

  • Key on a hash of (changelog + context, resolved prompt, model, provider, language, temperature) — anything that changes the output changes the key.
  • Store under the existing .ai-release-notes/ directory; add a cache directory to .gitignore.
  • --no-cache to bypass, and a way to clear it.

Provider prompt caching

  • The system prompt, scope guard, and instructions are identical across every call in a run. Mark them as cacheable where the provider supports it (Anthropic and OpenAI both do) — this is a straight discount on multi-language and multi-release runs.

Partial-failure tolerance

  • Audit the multi-call paths in src/generator.ts and src/release-document.ts.
  • A failure on call N must preserve calls 1..N-1, report exactly what succeeded, and let a re-run resume rather than restart.

Acceptance criteria

  • Re-running an identical range makes zero model calls and reports a cache hit
  • Any change to prompts, model, provider, or context misses the cache
  • --no-cache bypasses; cache directory is gitignored and documented
  • Prompt caching is enabled for providers that support it, and the token report reflects it
  • A forced failure mid multi-language run preserves completed languages
  • The run report distinguishes generated / cached / failed per output

Files

src/llm.ts, src/generator.ts, src/release-document.ts, src/config.ts, docs/configuration.md

Notes

The AI SDK retries transient errors by default, so this issue is about spend and resumability, not retry logic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:llmModel calls, prompts, cachingeffort:MA few daystier:reliabilityCost, caching, resumability

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions