Skip to content

feat(ux): API-key guidance + save_api_key — no more silent "can't search"#98

Merged
QodeXcli merged 1 commit into
mainfrom
feat/api-key-guidance
Jul 2, 2026
Merged

feat(ux): API-key guidance + save_api_key — no more silent "can't search"#98
QodeXcli merged 1 commit into
mainfrom
feat/api-key-guidance

Conversation

@QodeXcli

@QodeXcli QodeXcli commented Jul 2, 2026

Copy link
Copy Markdown
Owner

User-friendliness fix for the "models are set up but web tools silently can't work" trap.

The flow it creates

  1. A web task needs search/extract; no FIRECRAWL/TAVILY/BRAVE key is set.
  2. The tool failure now says exactly: get a free key at (per service, with what it unlocks) → then paste it here in chat — or add it to ~/.qodex/.env / export it.
  3. If the user pastes the key, the agent calls the new save_api_key tool: stored via the existing setEnvKey (~/.qodex/.env, chmod 600, atomic, same place provider add uses) and loaded into process.env live — the blocked step retries in the same session, no restart.

Pieces

  • key-guidance.ts (PURE): service registry + keyGuidance / webKeyStatus / missingWebKeysGuidance (fires only when zero content-grade keys are set — one key set → no nagging)
  • save_api_key tool: validates env-var name + value shape (rejects whitespace pastes); never echoes or logs the value; use-only-with-a-user-pasted-key in the description
  • web_search failure summary + Firecrawl/Tavily/Brave key errors now carry the guidance
  • Dashboard Health → "Web search" badge: green when any content-grade key is set, else a concrete suggestion (optional input → fully back-compat)

+9 tests (guidance content, no-nag gate, health badge, tool validation incl. never-echo). Full suite green, tsc clean.

…rch"

The failure this removes: a user sets up models, asks for a web task, and Firecrawl/Tavily/Brave
are skipped for lack of a key — the task limps on the keyless fallback or fails, and the user
never learns why or what to do.

- key-guidance.ts (PURE): registry of web service keys (Firecrawl/Tavily/Brave — URL, free-tier,
  what each unlocks) + keyGuidance(env) + missingWebKeysGuidance(env) — fires only when NO
  content-grade key is set (one key set → no nagging).
- save_api_key tool: when the user pastes a key in chat ("set it for me"), stores it via the
  existing setEnvKey (~/.qodex/.env, chmod 600, atomic) AND loads it into process.env so the
  blocked task retries in the SAME session. Validates the var name/value; the value is never
  echoed or logged.
- web_search failure paths + the three keyed backends now return that guidance: get a free key
  at <url> → paste it in chat (agent saves + retries) or add to ~/.qodex/.env.
- Dashboard Health gains a "Web search" badge: green when any content-grade key is set; else
  "keyless fallback only — get a free Firecrawl key at …" (input optional → old callers/tests
  untouched).
@QodeXcli QodeXcli merged commit 2599bba into main Jul 2, 2026
2 checks passed
@QodeXcli QodeXcli deleted the feat/api-key-guidance branch July 2, 2026 01:41
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.

1 participant