Skip to content

Claude runner: Bedrock client + forced-tool output + retry (claude/runner.py) #9

Description

@GeoSpark

The Bedrock client boundary. Isolate and test it hard. See DESIGN.md §8 (invocation).

Scope

  • backend/claude/runner.py: wrap the anthropic[bedrock] AnthropicBedrock client (region + AWS credential chain). One call = one Messages request with the doc-bundle prefix (cached), the examine/dedup/categorize prompt, and a forced output tool whose schema is the Finding list (tool_choice forces it).
  • Structured output comes back as the tool-call input (schema-valid JSON); Pydantic re-validates as a backstop with a small capped retry on mismatch.
  • Per-request timeout; parse and accumulate exact token usage (input / output / cache-read / cache-write) from each response.

Depends on

#2

Test approach

TDD at the mocked client boundary. Stub the Bedrock client; feed canned tool-call responses: valid, schema-violating (retry then fail), timeout. Assert forced-tool wiring, retry cap, and usage accumulation. No real Bedrock calls in CI.

Acceptance

  • Forced-tool output validated via Pydantic; retry cap enforced.
  • Timeout enforced; per-response token usage (incl. cache tokens) surfaced.
  • Model ID and region passed explicitly (Bedrock anthropic.claude-* IDs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeHeadless Claude integration (mocked-boundary tests + eval corpus)enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions