Metadata
| Status | done |
|---|---|
| Assigned | agent-896 |
| Agent identity | f51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e |
| Created | 2026-04-27T22:00:26.473445511+00:00 |
| Started | 2026-04-27T22:22:52.910039062+00:00 |
| Completed | 2026-04-27T22:45:37.181123057+00:00 |
| Tags | eval-scheduled |
| Tokens | 7594732 in / 35083 out |
Description
Description (rewritten 2026-04-27 evening — user clarification)
The user's contract: wg init -m qwen3-coder -e https://lambda01.tail334fe6.ts.net:30000 --executor nex MUST be sufficient to make tasks run on that endpoint. No env vars. No follow-up config edits. No [native_executor] api_key workaround. If the endpoint actually requires a key, the user will configure it via workgraph config (not env vars), and only when the endpoint rejects with 401.
User quote (exact): 'I want the init command that I uttered to be sufficient to set it up so that it works with that endpoint. Missing the key is not a problem. It's only a problem... like we'll see if we need a key. And it shouldn't be that I have to set a random ass environmental variable and maintain that. It should be in our config.'
Bug
Today (2026-04-27) the native executor crashes immediately when running any task whose model resolves to a non-Anthropic provider:
[native-exec] Starting agent loop for task '...' with model 'qwen3-coder', exec_mode 'full', max_turns 100
Error: Failed to initialize OpenAI-compatible client
Caused by:
No Anthropic API key found. Set ANTHROPIC_API_KEY environment variable, add [native_executor] api_key to .workgraph/config.toml, or create ~/.config/anthropic/api_key
[wrapper] Agent exited with code 1
The error is wrong on every axis:
- Model is qwen3-coder via OAI-compat — Anthropic key is irrelevant.
- The Tailscale endpoint at lambda01.tail334fe6.ts.net does not require a key. Workgraph should not pre-emptively reject.
- Demanding env vars violates the user's hard requirement: credentials live in workgraph config, period.
Earlier 'fix' tasks (agency-picks-claude, wg-nex-resume-311, chat-agent-loops-2, wg-evaluate-record — all marked Done) addressed plan resolution upstream but did NOT fix this client init precondition. Native executor remains 100% broken for autohaiku.
Required (this is the contract — do not narrow it)
1. No env-var fallback in the credential path
The native executor must NOT consult ANTHROPIC_API_KEY, OPENAI_API_KEY, OPENROUTER_API_KEY, or any other env var when initializing a client. Any such lookup is a bug. Credentials come from workgraph config exclusively.
2. No precondition check that gates on key presence
Client init must succeed when no key is configured. The HTTP layer just won't send an Authorization header. If the endpoint requires one and rejects with 401, surface THAT error to the user with a message that points at the right config block to add the key.
This means the current code path that errors with 'No Anthropic API key found ... before any HTTP call' is wrong by design and must be removed for all providers, not just OAI-compat. Even for direct anthropic:* / claude:* models, the right behavior is 'try without; if 401, surface a clear error pointing at config'.
3. wg init is sufficient
After running:
wg init -m qwen3-coder -e https://lambda01.tail334fe6.ts.net:30000 --executor nex
the resulting config must let wg service start dispatch tasks against that endpoint with no further user action. If the endpoint requires a key, wg init should accept it via flag (--api-key or similar) and write it into the config. If wg init is invoked without a key flag, no key is configured, and that's fine.
4. Per-endpoint credentials in [llm_endpoints.<name>]
Where credentials ARE configured, they live in the endpoint block:
[[llm_endpoints.endpoints]]
name = "lambda01"
provider = "oai-compat"
url = "https://lambda01.tail334fe6.ts.net:30000"
api_key = "..." # OPTIONAL. Empty/absent = no auth header sent.
The native executor pulls the key for the endpoint it is about to call — not from a global env var, not from a generic [native_executor] block, not from ~/.config/anthropic/api_key.
5. Error messages name the right config path
When the endpoint rejects (401/403), the user-facing error must say something like 'Endpoint rejected request — set api_key under [llm_endpoints.] in .' Never reference env vars in the user-facing error.
Files likely to touch
- src/executors/native/ — client init for OAI-compat / openrouter / anthropic. Remove the 'require key on init' guard. Remove env var lookups.
- src/dispatch/handler_for_model.rs — provider resolution; ensure provider derives correctly from model prefix and routes to the right endpoint config block.
- src/config/ — ensure
[llm_endpoints.*]per-endpoint api_key is read; remove[native_executor] api_keyif it exists OR keep as last-resort but document it as deprecated; remove~/.config/anthropic/api_keyfile lookup entirely. - src/commands/init.rs — ensure
wg init -m <model> -e <url> --executor nexwrites a complete[llm_endpoints.endpoints]block; accept optional--api-keyflag to populate it. - All error message construction sites that reference ANTHROPIC_API_KEY env var → rewrite to point at config.
Validation (live smoke required — per memory feedback_assertion_driven_live_smoke)
- Failing test first: native executor + model=local:qwen3-coder + endpoint configured + NO env vars + NO api_key in config → client init succeeds; HTTP call goes out without Authorization header; if endpoint accepts (Tailscale does), task runs.
- Failing test for 401 path: endpoint configured to require key + no key in config → client init STILL succeeds; HTTP call returns 401; user-visible error names the [llm_endpoints.] config block, NOT env vars.
- Failing test for env var ignored: ANTHROPIC_API_KEY=ignored-junk in env + model=local:qwen3-coder + key configured in [llm_endpoints.lambda01] → request uses the configured key, NOT the env var.
-
Failing test for wg init:
wg init -m qwen3-coder -e https://example.invalid --executor nexin a tmpdir, thenwg listruns without errors; config has a complete [llm_endpoints.endpoints] block for that endpoint. - grep src/ for ANTHROPIC_API_KEY / OPENAI_API_KEY / OPENROUTER_API_KEY env var lookups → only allowed in tests/ or migration code; main runtime never reads them.
-
Live smoke against /home/erik/autohaiku: with current config (no env vars),
wg --dir /home/erik/autohaiku/.wg spawn-task quality-pass-haiku-system-setupreaches at least 'in-progress' without an exit-1 due to client init. - cargo build + cargo test pass with no regressions
-
Update wg-nex / autohaiku setup docs to reflect: 'credentials are configured in workgraph config under [llm_endpoints.], never env vars;
wg initwrites the right block; missing key is fine unless the endpoint rejects'
Depends on
Required by
- (none)
Log
- 2026-04-27T22:00:26.456472167+00:00 Task paused
- 2026-04-27T22:00:32.554563067+00:00 Task published
- 2026-04-27T22:01:26.871679609+00:00 Lightweight assignment: agent=Careful Programmer (f5143935), exec_mode=full, context_scope=task, reason=Careful Programmer is ideal for this correctness-critical native executor bug fix spanning client initialization, config resolution, and error messaging across multiple files with strict validation requirements.
- 2026-04-27T22:01:28.075449098+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-27T22:01:37.200980731+00:00 Starting investigation into native executor client init key resolution
- 2026-04-27T22:08:21.696103697+00:00 Build success. Now reproducing the live bug to confirm root cause.
- 2026-04-27T22:10:56.391203326+00:00 Reproduced bug. local:qwen3-coder works (connects to lambda01); bare qwen3-coder fails with 'No Anthropic API key found' from OAI-compat init path. Now writing test + fix.
- 2026-04-27T22:18:08.225160970+00:00 Task marked as failed: Agent exited with code 1
- 2026-04-27T22:22:50.566582807+00:00 Task reset for retry from failed (attempt #2)
- 2026-04-27T22:22:52.910041757+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-27T22:23:01.116714050+00:00 Resuming from prior attempt — provider.rs + integration_native_coordinator.rs have uncommitted changes. Inspecting state.
- 2026-04-27T22:38:55.992604624+00:00 Core fix complete: provider.rs never bails on missing key, env vars not consulted, 401 surfaces config-pointing error. 6 per-provider tests + 3 wire-contract tests + wg init e2e + env-var audit all green. Now installing binary and live-smoke against autohaiku.
- 2026-04-27T22:45:19.308517663+00:00 Committed: 6f75abfa1 — pushed to remote on branch wg/agent-887/native-executor-client
- 2026-04-27T22:45:37.181126313+00:00 Task marked as done