Skip to content

fix(config,providers): resolve api_key, model lookup, and fallback bugs (#2371, #2286, #2334)#2372

Open
SaiBalusu-usf wants to merge 6 commits intosipeed:mainfrom
SaiBalusu-usf:refactor/agent-loop-decomposition
Open

fix(config,providers): resolve api_key, model lookup, and fallback bugs (#2371, #2286, #2334)#2372
SaiBalusu-usf wants to merge 6 commits intosipeed:mainfrom
SaiBalusu-usf:refactor/agent-loop-decomposition

Conversation

@SaiBalusu-usf
Copy link
Copy Markdown

@SaiBalusu-usf SaiBalusu-usf commented Apr 6, 2026

Summary

Test plan

  • TestModelConfig_APIKeySingular — singular api_key populates APIKeys
  • TestModelConfig_APIKeysPlural — plural api_keys still works
  • TestModelConfig_APIKeyBothForms — both forms merge correctly
  • TestModelConfig_APIKeyDuplicate — deduplication works
  • TestGetModelConfig_ByModelID — lookup by full model ID and bare ID
  • TestClassifyError_ModelNotFound — 404 and "no endpoints" classified correctly
  • TestFailoverError_IsRetriablemodel_not_found is retriable

Closes #2371, closes #2286, closes #2334

🤖 Generated with Claude Code

SaiBalusu-usf and others added 5 commits February 23, 2026 20:43
- Extract ContextCompressor (compression, summarization, token estimation) from AgentLoop

- Extract ToolExecutor (tool dispatch, result routing, context updates) from AgentLoop

- Create named constants replacing magic numbers (retry limits, thresholds, timeouts)

- Replace fragile string-matching error detection with structured IsContextWindowError()

- Add contextWindowPatterns and FailoverContextWindow to error classifier

- Refactor provider factory to table-driven registry approach

- Add graceful shutdown with context cancellation and WaitGroup

- Net reduction of ~143 lines from loop.go via component extraction
Resolve conflicts between the decomposed agent loop architecture and
main's new features (media store, voice transcription, command registry,
MCP servers, parallel tool execution, model routing, and new providers).

Conflict resolution strategy:
- Keep decomposed components (ContextCompressor, ToolExecutor) alongside
  new features (mediaStore, transcriber, cmdRegistry)
- Take main's parallel tool execution (more advanced than sequential ToolExecutor)
- Keep ToolExecutor.UpdateToolContexts for context injection
- Take main's timeout error detection + use extracted IsContextWindowError helper
- Add selectCandidates for model routing support
- Add new providers (litellm, vivgrid, avian, minimax) to standardProviderRegistry
  and modelInferenceRegistry, maintaining the data-driven refactored pattern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ror classifier

- Fix token estimation regression in context_compressor (missing context,
  shutdown wiring, correct token counting)
- Add EstimateTokens tests in context_compressor_test.go
- Wire graceful shutdown in loop.go, remove dead summarizing field
- Add iteration number to tool_executor logs, fix missing ctx
- Tighten invalidparameter regex in error_classifier to avoid false positives
- Add IsContextWindowError tests in error_classifier_test.go
- Reduce duplication in factory.go with simpleInference helper
- Update README with new providers (mistral, minimax, avian) and features

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflicts by accepting main's versions for loop.go, factory.go,
types.go, and README.md. Remove obsolete branch files (constants.go,
context_compressor.go, context_compressor_test.go, tool_executor.go) that
were superseded by main's ContextManager system. Retain contextWindowPatterns
and IsContextWindowError additions to error_classifier.go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gs (sipeed#2371, sipeed#2286, sipeed#2334)

- Accept legacy "api_key" (singular string) in ModelConfig JSON via custom
  UnmarshalJSON, fixing silent key drop that caused 401 auth errors
- Extend findMatches to fall back to Model field and bare model ID when
  ModelName doesn't match, fixing thinking_level lookup failures
- Classify HTTP 404 and "no endpoints found" as FailoverModelNotFound so
  the fallback chain correctly tries the next candidate instead of aborting

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sipeed-bot sipeed-bot bot added type: enhancement New feature or request domain: provider go Pull requests that update go code labels Apr 6, 2026
@SaiBalusu-usf SaiBalusu-usf changed the title feat(providers): add IsContextWindowError and context window patterns fix(config,providers): resolve api_key, model lookup, and fallback bugs (#2371, #2286, #2334) Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: provider go Pull requests that update go code type: enhancement New feature or request

Projects

None yet

1 participant