fix(gateway): avoid local fallback after accepted agent runs#11
Open
lionrooter wants to merge 7 commits intomainfrom
Open
fix(gateway): avoid local fallback after accepted agent runs#11lionrooter wants to merge 7 commits intomainfrom
lionrooter wants to merge 7 commits intomainfrom
Conversation
Preserve explicit agent IDs for isolated cron jobs instead of silently downgrading to main. Harden wake routing for legacy unqualified session keys so the target session is not dropped. Add regression coverage for isolated Maclern cron runs and guard against agent:main fallback.
Connect the existing provider-usage tracking infrastructure to the model fallback pipeline so routing decisions consider real-time subscription quota state. This closes the observation→action gap where usage was tracked comprehensively but never influenced model selection. New files: - complexity-tier.ts: Lightweight prompt complexity classifier (SIMPLE/MEDIUM/COMPLEX/REASONING) that maps to model preferences (local qwen for simple, cheap CLIs for medium, premium for complex) - provider-usage.cache.ts: 90s TTL cache for provider usage summary to avoid API call storms in the hot path Changes: - model-fallback.ts: reorderCandidatesByBudget() runs after resolveFallbackCandidates() and scores candidates by quota state, burn-rate projection, reset-time awareness, and complexity tier match - provider-usage.shared.ts: resolveUsageProviderIdForRouting() maps CLI providers (claude-cli, codex) to their subscription quota providers - provider-usage.ts: barrel re-exports for new functions Feature flags: BUDGET_ROUTING_DISABLED=1, BUDGET_ROUTING_ENFORCEMENT=strict Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…atus RPC Records recent model routing decisions (tier, scores, reorder, selected model) in a 50-entry ring buffer and exposes them via a new gateway RPC endpoint for Command Post dashboard visibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
agentruncallGateway()flowsChanges
GatewayRequestAcceptedErrorinsrc/gateway/client.tsackReceivedforexpectFinal:truerequestscallGateway()clientsagentCliCommand()from falling back to embedded execution after gateway acceptanceValidation
node_modules/.bin/vitest run src/gateway/client.test.ts src/gateway/call.test.ts src/commands/agent-via-gateway.test.tsnode dist/index.js agent --agent cody --message 'Final smoke after gateway 1006 fix. Reply only OK.' --json --timeout 30status: "ok"andOKNotes
budget.routing-statuslog spam currently visible in the gateway logs.