Skip to content

fix(chat): skip provider key-prefix validation for custom base_url#258

Merged
veithly merged 10 commits intomainfrom
fix/skip-key-validation-custom-baseurl
Feb 9, 2026
Merged

fix(chat): skip provider key-prefix validation for custom base_url#258
veithly merged 10 commits intomainfrom
fix/skip-key-validation-custom-baseurl

Conversation

@veithly
Copy link
Collaborator

@veithly veithly commented Feb 9, 2026

Summary

Fix provider/API-key prefix validation behavior for custom proxy endpoints.

When a custom/non-default base_url is configured (for example OpenAI-compatible proxy gateways), the strict provider key-prefix heuristic should not run.

What changed

  • In spoon_ai/chat.py partial override flow:
    • compute final_base_url
    • add _should_validate_provider_api_key(provider_name, base_url, config_manager)
    • only enforce _validate_provider_api_key_match(...) when:
      • effective base_url is empty, or
      • effective base_url equals provider default base_url
  • If custom base_url is used, provider key-prefix validation is skipped.

Why

Key-prefix checks are heuristic-based and can reject valid proxy usage (e.g. cliproxy/OpenAI-compatible gateways) where provider identity is determined by endpoint behavior, not key prefix.

Tests

Added tests/test_chatbot_provider_validation.py:

  1. test_api_key_validation_runs_on_default_base_url
  2. test_api_key_mismatch_skipped_on_custom_base_url

Run:

/home/google/project/spoon-bot/.venv/bin/python -m pytest tests/test_chatbot_provider_validation.py -q

Result: 2 passed

…s used

- Add _should_validate_provider_api_key() helper
- Only enforce provider/API key prefix validation when effective base_url
  is provider default (or empty)
- Keep strict behavior for default endpoints
- Add focused tests for default vs custom base_url behavior
Root causes of slow/off-topic skill responses:
1. Auto-activated skills never cleaned up after each turn
2. Skill tools injected but never removed on deactivation
3. LLM intent matching ran even when trigger matches existed

Changes:
- Add _run_with_auto_skills() for ephemeral per-turn activation/cleanup
- Add _sync_skill_tools() to add/remove tools in sync with active skills
- Skip LLM intent analysis when keyword triggers already match
- Add include_default_paths flag to SkillLoader/SkillManager
- Make ToolManager.remove_tool() safe on missing tools
- Add tests for ephemeral activation, stale tool removal, intent fallback
- Add SKILL_PERF_ANALYSIS.md documenting root causes and fixes
- implement _map_mcp_tool_name on SpoonReactSkill
- handle proxy_ prefixed MCP tool names from OpenAI-compatible gateways
- avoid runtime AttributeError during skill-triggered MCP tool execution
- when _map_mcp_tool_name resolves to a local tool name,
  run via available_tools.execute instead of call_mcp_tool
- prevents local tools (e.g. shell/image skill script tools) from being
  incorrectly routed to MCP client
- increase base_timeout to 90s minimum (was 25s)
- accommodate slow proxy endpoints like cliproxy on HuggingFace Spaces
- prevents premature tool selection timeouts on first turn
- ProviderConfig.timeout was 30s, but provider init uses 300s
- this caused config to override provider's better default
- align default timeout with OpenAI-compatible provider expectations
- SpoonReactMCP was missing tool name mapping method
- prevents AttributeError when MCP fallback path is triggered
- aligns with SpoonReactSkill fix in 46e6185
Root cause: common_defaults['timeout']=30 in ConfigurationManager was
overriding the ProviderConfig dataclass default, causing httpx to timeout
prematurely when using slow proxy endpoints like cliproxy.

Fixed in two places:
- ProviderConfig.timeout: int = 300 (dataclass default)
- common_defaults['timeout']: 300 (provider config dict fallback)

This fixes the 90s timeout issue where direct SDK calls worked but
gateway agent.run() calls timed out.
@veithly veithly merged commit edd17e4 into main Feb 9, 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.

1 participant