Skip to content

runtime: default LLM verbs to Claude Code, keep Gemini selectable#21

Merged
vinodhalaharvi merged 1 commit into
mainfrom
claude/runtime-claude-code-default
May 25, 2026
Merged

runtime: default LLM verbs to Claude Code, keep Gemini selectable#21
vinodhalaharvi merged 1 commit into
mainfrom
claude/runtime-claude-code-default

Conversation

@vinodhalaharvi-claude
Copy link
Copy Markdown
Collaborator

What

The in-memory runtime's LLM verbs (summarize, ask, analyze, and the search fallback) were hardwired to Gemini (geminiCall → r.gemini, requiring GEMINI_API_KEY). They now default to Claude Code — the claude CLI run as a subprocess, authenticated by the CLI's own local login, no API key — consistent with the worker and loom. Gemini stays fully available, selectable (per the 'keep GEMINI_API_KEY' ask).

New: pkg/claude/claudecode.go

ClaudeCodeClient runs claude -p <prompt> --output-format json; same Chat(ctx, prompt) shape as ClaudeClient, drop-in, no key.

Runtime

  • New llmChatter seam; Runtime.llm used by verb completions
  • RuntimeConfig.LLMBackend: claude-code (default, no key) | gemini (needs key) | claude (Anthropic API). Empty ⇒ claude-code. Falls back to Claude Code if a named backend's client is unavailable, so verbs always work
  • geminiCall routes through r.llm (name kept so every calling verb is unchanged); raw Gemini used when LLMBackend==gemini (via a small adapter) or as last-resort fallback

CLI (cmd/agentscript)

  • New -llm flag (claude-code | gemini | claude), default claude-code
  • GEMINI_API_KEY only required for -llm=gemini (old hard -n/-i requirement relaxed)
  • Reads ANTHROPIC_API_KEY (or legacy CLAUDE_API_KEY) for the claude backend

scriptmem

MemoryConfig.LLMBackend added + forwarded, so loom's memory execution picks the LLM too; defaults to claude-code.

Verified

  • read "/tmp/notes.txt" >=> summarize (no keys) → routes to Claude Code (errors only because this sandbox lacks the claude binary — proving the route; runs on a machine with claude installed)
  • -llm=gemini → correctly demands GEMINI_API_KEY
  • file-read half needs nothing; backward compatible
Step Result
go vet / gofmt / staticcheck
go test -race ./pkg/...
go build ./...

Now you can explore in-memory research on Claude Code, no key:

agentscript -e 'read "notes.txt" >=> summarize'
agentscript -e 'search "topic" >=> analyze "key risks" >=> ask "what should I do?"'
agentscript -e '( search "Google" >=> analyze "strengths" <*> search "Microsoft" >=> analyze "strengths" ) >=> merge >=> ask "who is winning?"'

(search still uses the LLM fallback unless SEARCH_API_KEY is set for real web search.)

The in-memory runtime's LLM verbs (summarize, ask, analyze, and the
search fallback) were hardwired to Gemini (geminiCall → r.gemini,
requiring GEMINI_API_KEY). They now default to Claude Code — the `claude`
CLI run as a subprocess, authenticated by the CLI's own local login, no
API key — consistent with the rest of the stack (worker, loom). Gemini
stays fully available, selectable per the user's 'keep GEMINI_API_KEY'
ask.

New (pkg/claude/claudecode.go):
  - ClaudeCodeClient: runs `claude -p <prompt> --output-format json` and
    returns the result. Same Chat(ctx, prompt) (string, error) shape as
    ClaudeClient, so it's a drop-in. No API key.

Runtime (internal/agentscript/runtime.go):
  - New llmChatter seam { Chat(ctx, prompt) (string,error) }; Runtime gains
    an `llm` field used by verb completions.
  - RuntimeConfig.LLMBackend selects the default: "claude-code" (default,
    no key) | "gemini" (needs GeminiAPIKey) | "claude" (Anthropic API,
    needs ClaudeAPIKey). Empty ⇒ claude-code. Falls back to Claude Code if
    a named backend's client isn't available, so verbs always work.
  - geminiCall now routes through r.llm (the historical name kept so every
    calling verb is unchanged); the raw Gemini client is used when
    LLMBackend==gemini (via a geminiChatAdapter mapping GenerateContent →
    Chat) or as a last-resort fallback. So 'read >=> summarize' runs on
    Claude Code with NO key; '-llm=gemini' + GEMINI_API_KEY still routes
    to Gemini.

CLI (cmd/agentscript):
  - New -llm flag (claude-code | gemini | claude), default claude-code.
  - GEMINI_API_KEY only required for -llm=gemini (the old hard requirement
    for -n/-i is relaxed — the default backend needs no key).
  - Reads ANTHROPIC_API_KEY (or legacy CLAUDE_API_KEY) for the claude verb
    / claude backend.

scriptmem.MemoryConfig gains LLMBackend, forwarded to the runtime, so a
front end (loom) can pick the memory backend's LLM too; defaults to
claude-code.

Verified: 'read "/tmp/notes.txt" >=> summarize' (no keys) routes to Claude
Code (errors only because this sandbox lacks the `claude` binary —
proving the route); '-llm=gemini' correctly demands GEMINI_API_KEY. The
file-read half needs nothing. Backward compatible: existing Gemini setups
work via -llm=gemini.

CI: vet, gofmt, staticcheck, go test -race ./pkg/..., go build ./... pass.
@vinodhalaharvi vinodhalaharvi merged commit 47a8044 into main May 25, 2026
1 check passed
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.

2 participants