fix(chat): skip provider key-prefix validation for custom base_url#258
Merged
fix(chat): skip provider key-prefix validation for custom base_url#258
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix provider/API-key prefix validation behavior for custom proxy endpoints.
When a custom/non-default
base_urlis configured (for example OpenAI-compatible proxy gateways), the strict provider key-prefix heuristic should not run.What changed
spoon_ai/chat.pypartial override flow:final_base_url_should_validate_provider_api_key(provider_name, base_url, config_manager)_validate_provider_api_key_match(...)when: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:test_api_key_validation_runs_on_default_base_urltest_api_key_mismatch_skipped_on_custom_base_urlRun:
Result:
2 passed