diff --git a/docs/environment-variables.md b/docs/environment-variables.md index b8c4e527b..aa0c31133 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -252,12 +252,14 @@ Anthropic web search uses `findAnthropicAuth()` from `packages/ai/src/utils/anth Related vars: -| Variable | Default / behavior | -| --------------------------- | ---------------------------------------------------- | -| `ANTHROPIC_SEARCH_API_KEY` | Highest-priority explicit search key | -| `ANTHROPIC_SEARCH_BASE_URL` | Defaults to `https://api.anthropic.com` when omitted | -| `ANTHROPIC_SEARCH_MODEL` | Defaults to `claude-haiku-4-5` | -| `ANTHROPIC_BASE_URL` | Generic fallback base URL for tier-4 auth path | +| Variable | Default / behavior | +| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ANTHROPIC_SEARCH_API_KEY` | API key used exclusively for the Anthropic web search provider. Highest-priority search auth; overrides `ANTHROPIC_API_KEY` / OAuth / Foundry for search calls without affecting chat completions.| +| `ANTHROPIC_SEARCH_BASE_URL` | Base URL used exclusively for the Anthropic web search provider. Overrides `ANTHROPIC_BASE_URL` (and `FOUNDRY_BASE_URL` in Foundry mode) for search calls. Defaults to `https://api.anthropic.com`.| +| `ANTHROPIC_SEARCH_MODEL` | Search model override. Defaults to `claude-haiku-4-5`. | +| `ANTHROPIC_BASE_URL` | Generic fallback base URL for the tier-4 auth path (`ANTHROPIC_API_KEY` + base URL) when no search-specific base URL is set. | + +Use `ANTHROPIC_SEARCH_API_KEY` + `ANTHROPIC_SEARCH_BASE_URL` to keep chat routed through an enterprise gateway (`ANTHROPIC_BASE_URL` or `CLAUDE_CODE_USE_FOUNDRY=true`) while pointing web search at a direct Anthropic endpoint, or vice versa. ### Perplexity OAuth flow behavior flag diff --git a/docs/tools/web_search.md b/docs/tools/web_search.md index f47a1b968..3de6ff6b0 100644 --- a/docs/tools/web_search.md +++ b/docs/tools/web_search.md @@ -121,7 +121,11 @@ Streaming: none. `WebSearchTool.execute()` forwards its `AbortSignal` into `exec - `limit` / `num_search_results`: `params.numSearchResults ?? params.limit`, clamped to `1..20`, default `10`. - Output: `sources`, `requestId`. - **Anthropic** — `packages/coding-agent/src/web/search/providers/anthropic.ts` - - Availability: `findAnthropicAuth()` from `@oh-my-pi/pi-ai`. + - Availability: `ANTHROPIC_SEARCH_API_KEY` env var, otherwise `findAnthropicAuth()` from `@oh-my-pi/pi-ai` (stored Anthropic OAuth/API-key credentials). + - Env overrides specific to search (do not affect chat completions): + - `ANTHROPIC_SEARCH_API_KEY` — highest-priority search auth; overrides `ANTHROPIC_API_KEY` / OAuth / `ANTHROPIC_FOUNDRY_API_KEY` for the search call only. + - `ANTHROPIC_SEARCH_BASE_URL` — overrides `ANTHROPIC_BASE_URL` (and `FOUNDRY_BASE_URL` in Foundry mode); defaults to `https://api.anthropic.com`. + - `ANTHROPIC_SEARCH_MODEL` — search model; defaults to `claude-haiku-4-5`. - Querying: Claude Messages API with web-search tool enabled. - `max_tokens` and `temperature` pass through. - `limit` and `num_search_results` are collapsed together before dispatch: `num_results = params.numSearchResults ?? params.limit`. diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 2c777c78b..c457b1d50 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -12,6 +12,7 @@ - Changed the eval `parallel()` / `pipeline()` helpers to drop their `concurrency` argument and run as wide as a `task` tool batch. The worker-pool ceiling now tracks the `task.maxConcurrency` setting (default 32; `0` = run every item at once) resolved live from the host via a new `__concurrency__` bridge, instead of the old per-call `concurrency` option that defaulted to 4 and capped at 16. This stops eval fan-outs from under-using the parallelism the session is configured for. - Changed subagent / `agent://` output ids from a numeric prefix scheme (`0-Anna`, `1-Bob`, nested `0-Anna.1-Bob`) to a name-first scheme: the requested name is used verbatim and a `-2`/`-3`/… suffix is added only when the same name recurs within a session (`Anna`, `Anna-2`, `Anna-3`). Nested ids stay grouped under the parent (`Anna.Bob`) and the live task widget renders them as `Anna>Bob`. The main agent's IRC id is now `Main` (was `0-Main`). `AgentOutputManager` still scans existing `.md` outputs on resume so it never reuses a name that would clobber a prior output. - Changed resuming a session that belongs to a different project to switch the process into that project's working directory. `pi --resume` and the in-session `/resume` picker now `chdir` into the resumed session's `cwd` and re-scope every cwd-derived input — project dir, **project settings** (`.claude/settings.yml`, `.omp/settings.json`, path-scoped `enabledModels`/`disabledProviders`), plugin roots, capabilities, slash commands, and the ssh tool — so tools, discovery, configuration, and commands all follow the resumed project. The `SessionManager` adopts the resumed session's own `cwd`/session directory on load (rolled back if the switch fails). +- Documented `ANTHROPIC_SEARCH_API_KEY` and `ANTHROPIC_SEARCH_BASE_URL` more thoroughly in `docs/environment-variables.md`, surfaced them in `docs/tools/web_search.md`'s Anthropic provider section, and added `ANTHROPIC_SEARCH_BASE_URL` to `omp --help`'s env-var summary so the search-only overrides are discoverable alongside `ANTHROPIC_SEARCH_API_KEY` ([#1694](https://github.com/can1357/oh-my-pi/issues/1694)). ### Fixed diff --git a/packages/coding-agent/src/cli/args.ts b/packages/coding-agent/src/cli/args.ts index 91696182b..f62adbc8a 100644 --- a/packages/coding-agent/src/cli/args.ts +++ b/packages/coding-agent/src/cli/args.ts @@ -287,7 +287,8 @@ export function getExtraHelpText(): string { PERPLEXITY_API_KEY - Perplexity web search (API) PERPLEXITY_COOKIES - Perplexity web search (session cookie) TAVILY_API_KEY - Tavily web search - ANTHROPIC_SEARCH_API_KEY - Anthropic search provider + ANTHROPIC_SEARCH_API_KEY - Anthropic web search (override; isolates search from main ANTHROPIC_API_KEY) + ANTHROPIC_SEARCH_BASE_URL - Anthropic web search base URL (override; pairs with ANTHROPIC_SEARCH_API_KEY) ${chalk.dim("# Configuration")} PI_CODING_AGENT_DIR - Session storage directory (default: ~/${CONFIG_DIR_NAME}/agent)