Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ANTHROPIC_WORKSPACE_ID=
# Must exactly match the approved rule. Default is inference-only; the current
# Console only offers workspace:developer, which requires operator approval.
ANTHROPIC_FEDERATION_SCOPE=workspace:inference
# Used only for Gitdog's generation fallback (GPT-6.1 Sol); no embeddings.
# Used only for Gitdog's generation fallback (GPT-6.2 Sol); no embeddings.
OPENAI_API_KEY=
# 32 random bytes, base64 (openssl rand -base64 32). Encrypts users' own
# provider keys at rest; changing it makes every saved key unreadable.
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
**Gitdog** is an AI-powered GitHub issue and discussion assistant.

- Repository-aware issue and discussion formatting, answers, and maintainer tagging
- Claude Opus 5.5 generation with GPT-6.1 Sol fallback (see [docs/ai-models.md](docs/ai-models.md))
- Claude Opus 5.5 generation with GPT-6.2 Sol fallback (see [docs/ai-models.md](docs/ai-models.md))
- Keyword repository index plus AI repository tools (search, read file) for code search
- Private workspace per user
- Free and Pro token quotas with optional prepaid token packs
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ organized, how to run it locally and what a pull request needs.
| -------- | -------------------------------------------------------------------- |
| Frontend | React 19, TypeScript, Vite, Tailwind CSS, react-i18next (en, ko, ja) |
| Backend | Convex |
| AI | Claude Opus 5.5 with GPT-6.1 Sol fallback; users' own keys optional |
| AI | Claude Opus 5.5 with GPT-6.2 Sol fallback; users' own keys optional |
| GitHub | GitHub App (OAuth, webhooks, repository access) |
| Payments | Lemon Squeezy |
| Hosting | Firebase Hosting |
Expand All @@ -31,7 +31,7 @@ organized, how to run it locally and what a pull request needs.
GitHub webhook ─▶ Convex ─▶ repository index (keyword search)
│
▼
Claude Opus 5.5 (GPT-6.1 Sol fallback)
Claude Opus 5.5 (GPT-6.2 Sol fallback)
│
▼
draft reply or review ─▶ approval ─▶ GitHub comment / PR review
Expand Down
7 changes: 5 additions & 2 deletions convex/_ai/chatBilling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,11 @@ export function getChatReservationLimits(
messages: ChatMessage[],
options?: ChatCompletionOptions,
): { inputTokenLimit: number; outputTokenLimit: number } {
// Every token is at least one byte, so the request size bounds its input
// tokens, and the cacheable prefix bounds the extra a cache write costs.
// The request size bounds its input tokens, and the cacheable prefix bounds
// the extra a Claude cache write costs. OpenAI caching is off; were it to
Comment thread
hyochan marked this conversation as resolved.
Resolved
// write a whole prompt, the serialized request covers it for any text whose
// tokens average over 1.25 bytes, and otherwise settlement holds the
// attempt for reconciliation instead of charging it.
const inputTokenLimit =
chatRequestBytes(messages, options) +
Math.ceil(
Expand Down
24 changes: 22 additions & 2 deletions convex/_ai/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const GENERATION_MODELS = {
effort: "medium",
},
openai: {
modelId: "gpt-6.1-sol",
name: "GPT-6.1 Sol",
modelId: "gpt-6.2-sol",
name: "GPT-6.2 Sol",
effort: "high",
},
} as const;
Expand Down Expand Up @@ -97,6 +97,18 @@ export const CHAT_MODELS: Record<
outputMultiplier: 5,
},
},
"gpt-6.2-sol": {
provider: "openai",
inputPer1M: 2,
outputPer1M: 10,
quotaWeight: 1,
cacheReadMultiplier: 0.05,
longContext: {
inputTokens: 272_000,
inputMultiplier: 2,
outputMultiplier: 1.5,
},
},
"gpt-6.1-sol": {
provider: "openai",
inputPer1M: 2,
Expand Down Expand Up @@ -190,13 +202,21 @@ export const USER_KEY_MODELS: Record<"anthropic" | "openai", UserKeyModel[]> = {
defaultEffort: "medium",
},
],
// Keys saved before GPT-6.2 Sol were checked against 6.1 and store no
Comment thread
hyochan marked this conversation as resolved.
Resolved
// model, so 6.1 stays the default they resolve to.
openai: [
{
modelId: "gpt-6.1-sol",
name: "GPT-6.1 Sol",
efforts: ["low", "medium", "high"],
defaultEffort: "high",
},
{
modelId: "gpt-6.2-sol",
name: "GPT-6.2 Sol",
efforts: ["low", "medium", "high"],
defaultEffort: "high",
},
],
};

Expand Down
2 changes: 2 additions & 0 deletions convex/_ai/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export type ChatCompletionOptions = {
topP?: number;
tools?: ToolDefinition[];
billingLabel?: string;
// How long the provider may take; the provider's default when unset.
timeoutMs?: number;
responseFormat?: {
name: string;
schema: Record<string, unknown>;
Expand Down
38 changes: 26 additions & 12 deletions convex/_ai/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async function request(
headers: Record<string, string>,
body: RecordValue,
deadline?: number,
timeoutMs = REQUEST_TIMEOUT_MS,
): Promise<{ data: RecordValue; requestId?: string }> {
let started = false;
let requestId: string | undefined;
Expand All @@ -66,7 +67,7 @@ async function request(
method: "POST",
headers: { "Content-Type": "application/json", ...headers },
body: serialized,
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
signal: AbortSignal.timeout(timeoutMs),
});
requestId =
response.headers.get("request-id") ??
Expand Down Expand Up @@ -291,6 +292,7 @@ export class ClaudeProvider implements AiProvider {
...(options?.tools?.length ? { tools: options.tools } : {}),
},
this.enforceDeadline ? CLAUDE_API_ENDS_AT : undefined,
options?.timeoutMs,
);
const counts = record(data.usage) ? data.usage : {};
// With fallbacks, top-level usage covers the attempt that produced the
Expand Down Expand Up @@ -521,28 +523,40 @@ export class OpenAIProvider implements AiProvider {
}
: {}),
},
undefined,
options?.timeoutMs,
);
const counts = record(data.usage) ? data.usage : {};
const billed = usage(counts.input_tokens, counts.output_tokens, requestId);
const details = record(counts.input_tokens_details)
? counts.input_tokens_details
: {};
// Should OpenAI still report cache usage, its writes and reads are part
Comment thread
hyochan marked this conversation as resolved.
Resolved
// of input_tokens and count as the input they cost on this model.
const cacheWrite = details.cache_write_tokens ?? 0;
const cacheRead = details.cached_tokens ?? 0;
if (
(details.cached_tokens ?? 0) !== 0 ||
(details.cache_write_tokens ?? 0) !== 0
) {
throw new ChatProviderRequestError(
"OpenAI returned unexpected prompt cache usage",
"ambiguous",
{ providerRequestId: requestId },
);
}
if (counts.total_tokens !== billed.totalTokens)
!tokens(counts.input_tokens) ||
!tokens(counts.output_tokens) ||
!tokens(cacheWrite) ||
!tokens(cacheRead) ||
cacheWrite + cacheRead > counts.input_tokens ||
counts.total_tokens !== counts.input_tokens + counts.output_tokens
)
throw new ChatProviderRequestError(
"OpenAI returned inconsistent usage metadata",
"ambiguous",
{ providerRequestId: requestId },
);
const billed = usage(
cacheAdjustedInputTokens(
this.modelId,
counts.input_tokens - cacheWrite - cacheRead,
cacheWrite,
cacheRead,
),
counts.output_tokens,
requestId,
);
try {
if (!Array.isArray(data.output)) throw new Error("Invalid output");
const history: Array<
Expand Down
2 changes: 2 additions & 0 deletions convex/pullRequests/internalAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ export const generate = internalAction({
beforeProviderStart: ensureCurrent,
activeProviderWaitMs: REVIEW_ACTIVE_PROVIDER_WAIT_MS,
});
// The metered route is the one that switches to the fallback provider.
runProvider = provider;
let result: Awaited<ReturnType<typeof reviewWithContext>>;
try {
if (discussion) run.discussionEntries = discussion.length;
Expand Down
12 changes: 12 additions & 0 deletions convex/pullRequests/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ const MAX_COVERAGE_PASSES = 8;
// up to 120. A coverage request starts only within 4 minutes of the action's
// start, so even the slowest one ends before the action is stopped.
const COVERAGE_REQUEST_CUTOFF_MS = 4 * 60_000;
// The closing synthesis reads the whole review and can take a reasoning model
// past the usual two minutes. It may run until this long after the action
// started (never less than two minutes nor more than five), which still leaves
// room for verification before Convex stops the action.
const FINAL_REQUEST_END_MS = 7 * 60_000;
// After the main review, focused second looks at the same source. Each one
// resends the main review's last request with only its closing state
// replaced, so the repository context and sources are read from the prompt
Expand Down Expand Up @@ -1610,6 +1615,13 @@ export async function reviewWithContext(args: {
maxTokens: REVIEW_OUTPUT_TOKENS,
billingLabel: "pr-review/final",
responseFormat: REVIEW_RESPONSE_FORMAT,
timeoutMs: Math.min(
5 * 60_000,
Math.max(
2 * 60_000,
actionStarted + FINAL_REQUEST_END_MS - Date.now(),
),
),
},
);
let final: Awaited<ReturnType<typeof chat>>;
Expand Down
15 changes: 10 additions & 5 deletions docs/ai-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and CLI never store provider keys.

- Primary: **Claude Opus 5.5** (`claude-opus-5-5`) at `medium` effort, with
Anthropic's server-side refusal fallback.
- Fallback: **GPT-6.1 Sol** (`gpt-6.1-sol`) at `high` reasoning effort through
- Fallback: **GPT-6.2 Sol** (`gpt-6.2-sol`) at `high` reasoning effort through
the OpenAI Responses API.
- Claude is used strictly before **2027-01-18 00:00 Asia/Seoul**
(`2027-01-17T15:00:00Z`); after that, new requests go to OpenAI.
Expand All @@ -31,7 +31,9 @@ those keys instead of Gitdog's:
- Each key runs the model and effort its owner chooses (web settings or
`gitdog provider-keys model`), checked against the key when chosen and when
the key is saved again. Anthropic: Claude Opus 5.5 (default, `medium`),
Sonnet 5.5 (`high`) or Haiku 5.5 (`medium`); OpenAI: GPT-6.1 Sol (`high`).
Sonnet 5.5 (`high`) or Haiku 5.5 (`medium`); OpenAI: GPT-6.1 Sol (default,
`high`; keys saved before 6.2 were checked against it) or GPT-6.2 Sol
(`high`).
Efforts are `low`, `medium` or `high`: requests are not streamed and stop
after two minutes, so Fable 5.1 and `xhigh`/`max` are not offered. Haiku
5.5 bills prompts over 100K tokens at 5x and has no server-side refusal
Expand Down Expand Up @@ -93,6 +95,7 @@ indexing costs no AI tokens.
| Model | Input per 1M tokens | Output per 1M tokens | Quota weight |
| ----------------- | ------------------- | -------------------- | ------------ |
| Claude Opus 5.5 | $4.00 | $20.00 | 2 |
| GPT-6.2 Sol | $2.00 | $10.00 | 1 |
| GPT-6.1 Sol | $2.00 | $10.00 | 1 |
| Claude Sonnet 5.5 | $2.00 | $10.00 | 1 (own keys) |
| Claude Haiku 5.5 | $0.10 | $0.50 | own keys |
Expand Down Expand Up @@ -129,10 +132,12 @@ the serving model as `servedModel`, and records its cost at that model's
price.

Sol prompts above 272K input tokens use 2x input and 1.5x output pricing.
Prompt caching is disabled, so recorded token counts map directly to the listed
uncached prices. Thinking tokens are included in the provider's output usage.
OpenAI prompt caching is turned off (explicit mode with no breakpoint), since
its automatic mode writes the whole prompt again whenever its end changes. If
OpenAI still reports cache usage, it is recorded like Claude's: a write at
1.25x and a read at 0.05x on GPT-6.2 Sol (0.1x on 6.1). Thinking tokens are included in the provider's output usage.
See [Claude pricing](https://platform.claude.com/docs/en/about-claude/pricing)
and [Sol pricing](https://developers.openai.com/api/docs/models/gpt-6.1-sol).
and [Sol pricing](https://developers.openai.com/api/docs/models/gpt-6.2-sol).

## Plans and token packs

Expand Down
6 changes: 5 additions & 1 deletion e2e/runPrReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { tmpdir } from "node:os";
import path from "node:path";
import assert from "node:assert/strict";
import { GENERATION_MODELS } from "../convex/_ai/config";
const deployment = "fortunate-chihuahua-679";
const root = path.resolve(import.meta.dirname, "..");
const logRoot = path.resolve(
Expand Down Expand Up @@ -171,7 +172,9 @@ try {
assert(["anthropic", "openai"].includes(row.provider));
assert.equal(
row.model,
row.provider === "anthropic" ? "claude-opus-5-5" : "gpt-6.1-sol",
row.provider === "anthropic"
? GENERATION_MODELS.anthropic.modelId
: GENERATION_MODELS.openai.modelId,
Comment thread
hyochan marked this conversation as resolved.
Resolved
);
// Opus 5.5 counts twice against quota on Gitdog's key.
assert.equal(
Expand All @@ -183,6 +186,7 @@ try {
"claude-opus-5-5": [4, 20],
"claude-opus-5": [5, 25],
"claude-opus-4-8": [5, 25],
"gpt-6.2-sol": [2, 10],
"gpt-6.1-sol": [2, 10],
};
const [inputPer1M, outputPer1M] =
Expand Down
2 changes: 1 addition & 1 deletion public/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The `gitdog` npm CLI (`npx gitdog@latest`) covers the same workflows as the web

### Free Plan - $0/month
- 100,000 one-time trial tokens on first sign-in
- Then use your own Anthropic or OpenAI API key (that usage never uses Gitdog tokens), with the model and effort you choose: Claude Opus 5.5, Sonnet 5.5 or Haiku 5.5, or GPT-6.1 Sol
- Then use your own Anthropic or OpenAI API key (that usage never uses Gitdog tokens), with the model and effort you choose: Claude Opus 5.5, Sonnet 5.5 or Haiku 5.5, or GPT-6.1 or 6.2 Sol
- Hard limit with no automatic overage charges
- Prepaid token packs available for additional usage
- All features included
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@
"purchase": "Purchase"
},
"tokenPricing": "Token Pricing",
"tokenPricingDescription": "Free starts with 100k one-time trial tokens and Pro includes 2.4M each month. Both stop at the available limit, which prepaid token packs can extend. Gitdog runs on Claude Opus 5.5, and each Opus token counts as 2 Gitdog tokens because it costs twice as much as the GPT-6.1 Sol fallback. Work that runs on your own API key never uses Gitdog tokens.",
"tokenPricingDescription": "Free starts with 100k one-time trial tokens and Pro includes 2.4M each month. Both stop at the available limit, which prepaid token packs can extend. Gitdog runs on Claude Opus 5.5, and each Opus token counts as 2 Gitdog tokens because it costs twice as much as the GPT-6.2 Sol fallback. Work that runs on your own API key never uses Gitdog tokens.",
"freeTokensLabel": "Trial tokens (one-time)",
"platformFeeLabel": "Prepaid token packs",
"billingLabel": "Billing",
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@
"purchase": "購入"
},
"tokenPricing": "トークン価格",
"tokenPricingDescription": "Freeは1回限りの100k体験トークンから始まり、Proには毎月2.4Mトークンが含まれます。どちらも利用可能な上限で停止し、プリペイドトークンパックで追加できます。GitdogはClaude Opus 5.5で動作し、OpusのトークンはフォールバックのGPT-6.1 Solの2倍のコストがかかるため、1トークンをGitdogトークン2つとして数えます。自分のAPIキーで実行される処理はGitdogのトークンを使いません。",
"tokenPricingDescription": "Freeは1回限りの100k体験トークンから始まり、Proには毎月2.4Mトークンが含まれます。どちらも利用可能な上限で停止し、プリペイドトークンパックで追加できます。GitdogはClaude Opus 5.5で動作し、OpusのトークンはフォールバックのGPT-6.2 Solの2倍のコストがかかるため、1トークンをGitdogトークン2つとして数えます。自分のAPIキーで実行される処理はGitdogのトークンを使いません。",
"freeTokensLabel": "体験トークン(1回限り)",
"platformFeeLabel": "プリペイドトークンパック",
"billingLabel": "課金",
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@
"purchase": "구매"
},
"tokenPricing": "토큰 가격",
"tokenPricingDescription": "Free는 1회 100k 체험 토큰으로 시작하고, Pro는 매월 2.4M 토큰을 포함합니다. 두 플랜 모두 사용 가능한 한도에서 중지되며 선불 토큰 팩으로 늘릴 수 있습니다. Gitdog은 Claude Opus 5.5로 실행되며, Opus 토큰은 GPT-6.1 Sol 대체 모델보다 비용이 두 배라 1개당 Gitdog 토큰 2개로 계산됩니다. 내 API 키로 실행되는 작업은 Gitdog 토큰을 쓰지 않습니다.",
"tokenPricingDescription": "Free는 1회 100k 체험 토큰으로 시작하고, Pro는 매월 2.4M 토큰을 포함합니다. 두 플랜 모두 사용 가능한 한도에서 중지되며 선불 토큰 팩으로 늘릴 수 있습니다. Gitdog은 Claude Opus 5.5로 실행되며, Opus 토큰은 GPT-6.2 Sol 대체 모델보다 비용이 두 배라 1개당 Gitdog 토큰 2개로 계산됩니다. 내 API 키로 실행되는 작업은 Gitdog 토큰을 쓰지 않습니다.",
"freeTokensLabel": "체험 토큰 (1회)",
"platformFeeLabel": "선불 토큰 팩",
"billingLabel": "결제",
Expand Down
Loading
Loading