feat: Agent SDK auto-detects Claude Code session — no API key needed locally

ANTHROPIC_API_KEY is optional: Agent SDK uses Claude Code OAuth
session when running locally (detects CLAUDE_CODE_SSE_PORT).
In CI, ANTHROPIC_API_KEY from secrets is used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
snomiao
2026-03-28 15:07:57 +00:00
parent 3690e98c79
commit c4a243060b
2 changed files with 4 additions and 8 deletions

View File

@@ -25,7 +25,7 @@ interface AgentOptions {
qaGuide: string
outputDir: string
geminiApiKey: string
anthropicApiKey: string
anthropicApiKey?: string // Optional — Agent SDK auto-detects Claude Code session
maxTurns?: number
timeBudgetMs?: number
}
@@ -518,7 +518,7 @@ ${issueContext}`
options: {
model: 'claude-sonnet-4-6',
systemPrompt,
apiKey: anthropicApiKey,
...(anthropicApiKey ? { apiKey: anthropicApiKey } : {}),
maxTurns,
mcpServers: { 'qa-agent': server },
allowedTools: [

View File

@@ -1938,13 +1938,9 @@ async function main() {
recordingStartMs = Date.now()
narrationSegments.length = 0
// Hybrid agent (Claude + Gemini) — requires ANTHROPIC_API_KEY
// Hybrid agent (Claude + Gemini)
// Uses ANTHROPIC_API_KEY in CI, or Claude Code OAuth session locally
const anthropicKey = process.env.ANTHROPIC_API_KEY
if (!anthropicKey) {
throw new Error(
'ANTHROPIC_API_KEY is required for issue reproduction. The Gemini-only agent has been removed due to low success rate.'
)
}
const { runHybridAgent } = await import('./qa-agent.js')
const issueCtx = opts.diffFile
? readFileSync(opts.diffFile, 'utf-8').slice(0, 6000)