Add provider retries and request metadata - #24
Merged
Conversation
- Introduce `GeneratedContent`, `LlmRequestMetadata`, `TokenUsage`, and `ProviderGeneratedContent` types to expose request duration and token usage. - Add `withRequestMetadata` helper to wrap provider responses with timing information. - Update `generateContent`, `generateCommitMessage`, and `refineCommitMessage` to return `GeneratedContent` instead of plain strings.
- Thread `GeneratedContent` through the commit/refine/interact flow so model, duration, and token usage are preserved end-to-end. - Extend `LlmRequestMetadata` with `ModelRequestMetadata` capturing provider, model, and effort. - Capture token usage from Anthropic, Gemini, and OpenAI provider responses and return `ProviderGeneratedContent`. - Add `renderCommitNote` and extend `renderPushNote` to show model, request duration, and token counts. - Introduce `withTransientRetry` helper in `src/infra/llm/retry.ts` and apply it to Anthropic API key and setup-token calls. - Configure Anthropic client with `maxRetries: 3` and a 120s timeout, and wrap errors with `cause` for retry classification.
- Delete `src/infra/llm/retry.ts` and drop `withTransientRetry` wrappers from both Anthropic auth paths. - Add `maxRetries: 3` and 120s timeout to OpenAI clients for API key and OAuth flows. - Configure Gemini `GoogleGenAI` with 120s timeout and 3 retry attempts via `httpOptions`. - Switch Gemini API key path from streamed iteration to a single `generateContent` call. - Switch Gemini OAuth path from `:streamGenerateContent?alt=sse` to `:generateContent` and parse the JSON response directly. - Replace `extractSSEEvent` and `accumulateSSEContent` with `parseOAuthResponse`, and share mapping via new `extractGeminiText` and `toGeneratedContent` helpers.
- Replace global `npm install -g pnpm` with `corepack enable` in PR validation workflow. - Use `pnpm install --frozen-lockfile` in CI to ensure reproducible installs. - Pin `packageManager` to `pnpm@10.33.0` in `package.json`. - Add `pnpm-workspace.yaml` defining the root package and allowing builds for `esbuild` and `protobufjs`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Add retry handling and richer request metadata after commit message generation.
What's New
LLM Request Metadata
GeneratedContentwraps generated text withLlmRequestMetadatafor model, effort, duration, and token usage.ProviderGeneratedContentso the router can attach shared request metadata.TokenUsageshape with optional counts.Provider Reliability
maxRetries: 3andtimeout: 120_000.httpOptions.generateContentJSON parsing for metadata support.Commit And Push Notes
Committednote with commit metadata and LLM request metadata.Testing & Feedback
pnpm run typecheck.pnpm run lint:ci.generateContentpayload.If you find any bugs or have recommendations for improvements, please open an issue and assign it to me.