Skip to content

Anthropic backend + tightened keyword fallback + LLM call hardening#4

Closed
Conalh wants to merge 1 commit into
codey/taskbound-action-credibilityfrom
feat/anthropic-backend-and-scope-tightening
Closed

Anthropic backend + tightened keyword fallback + LLM call hardening#4
Conalh wants to merge 1 commit into
codey/taskbound-action-credibilityfrom
feat/anthropic-backend-and-scope-tightening

Conversation

@Conalh
Copy link
Copy Markdown
Owner

@Conalh Conalh commented May 21, 2026

Summary

Layers on top of the codex slice on `codey/taskbound-action-credibility` (LLM scope-llm support + PR-body ingestion + `.taskbound.yml` config). Three independent improvements with regression tests.

1. Anthropic Messages API as a second LLM backend

Codex went OpenAI-only. Adding Anthropic, auto-routed by model-id prefix:

  • claude-* → Anthropic Messages API (ANTHROPIC_API_KEY), with prompt caching on the static system prompt (cache_control: { type: 'ephemeral' } on the system content block). Repeat invocations on the same Action job are cheap and fast.
  • Anything else → OpenAI Responses API (unchanged).

Structured output is forced via tool_choice: { type: 'tool', name: 'report_scope' }. Both providers return the same normalized InferredScope, sharing a single normalizeLlmScope helper, so the review pipeline doesn't know or care which one answered.

2. Tighter keyword fallback in isFileInScope

Previous behavior was "keyword appears anywhere in the path." A task saying "fix header" pulled src/auth/header-injection-fix.ts into scope.

Fix: split the path on / and ., require the keyword to appear as a substring of a segment. src/components/Header.tsx and src/styles/header.css still match (the basename segment contains "header"); unrelated paths don't.

3. LLM call hardening

A new shared callLlm wrapper:

  • 30-second timeout via AbortSignal.timeout — a hung Anthropic/OpenAI call cannot hang the GitHub Action.
  • 64KiB body cap via Content-Length check — a runaway response cannot OOM the runner.

Both backends go through it.

Verification

  • `npm run build` — clean.
  • `npm test` — 22/22 passing (18 prior + 4 new): Anthropic routing+caching, OpenAI regression, Anthropic failure fallback, keyword segment-matching.

Test plan

  • CI build-test job passes
  • TaskBound self-dogfood (advisory) runs without invoking the LLM path (no key in default workflows)

Layers on top of the codex slice that landed scope-llm support, PR-body
ingestion, and the .taskbound.yml config. Three independent improvements:

1. Anthropic Messages API as a second LLM scope-extraction backend,
   auto-routed by model-id prefix. 'claude-*' models go to Anthropic
   (with prompt caching on the static system prompt via cache_control
   on the system content block); anything else stays on the existing
   OpenAI Responses backend. Both paths return the same normalized
   InferredScope and share a single normalizeLlmScope helper, so the
   review pipeline doesn't know or care which provider answered.
   Structured output is forced via 'tool_choice: { type: tool, name:
   report_scope }' so the response is always JSON-shaped against the
   shared SCOPE_SCHEMA.

2. isFileInScope keyword fallback was 'substring anywhere in the path,'
   which over-matched: a task saying 'fix header' would pull
   src/auth/header-injection-fix.ts into scope. Now keywords must
   appear as a substring of a path segment (split on '/' and '.'), so
   src/components/Header.tsx and src/styles/header.css still match
   while unrelated files don't.

3. LLM calls now share a callLlm wrapper with a 30-second
   AbortSignal.timeout (a hung Anthropic/OpenAI call cannot hang the
   GitHub Action) and a 64KiB content-length cap (a runaway response
   cannot OOM the runner).

test/scope-anthropic-and-keyword.test.mjs locks the new behavior with
four cases: Anthropic routing+caching, OpenAI regression, Anthropic
failure fallback, and keyword segment-matching. Total suite 22/22 green.
@Conalh Conalh deleted the branch codey/taskbound-action-credibility May 21, 2026 20:29
@Conalh Conalh closed this May 21, 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