coderouter-cli 2.7.2__tar.gz → 2.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/CHANGELOG.md +40 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/PKG-INFO +1 -1
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/config/schemas.py +51 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/logging.py +40 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/metrics/collector.py +29 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/routing/fallback.py +216 -5
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/pyproject.toml +1 -1
- coderouter_cli-2.7.3/tests/test_fallback_empty_response.py +561 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/.gitignore +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/LICENSE +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/README.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/README.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/__main__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/adapters/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/adapters/anthropic_native.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/adapters/base.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/adapters/openai_compat.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/adapters/registry.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/cli.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/cli_stats.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/config/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/config/capability_registry.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/config/env_file.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/config/loader.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/cost.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/data/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/data/model-capabilities.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/doctor.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/doctor_apply.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/env_security.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/errors.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/gguf_introspect.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/_fingerprint.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/backend_health.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/context_budget.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/continuous_probe.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/drift_actions.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/drift_detection.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/memory_budget.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/memory_pressure.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/self_healing.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/guards/tool_loop.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/hardware.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/ingress/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/ingress/anthropic_routes.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/ingress/app.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/ingress/dashboard_routes.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/ingress/launcher_routes.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/ingress/metrics_routes.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/ingress/openai_routes.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/language_tax.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/metrics/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/metrics/prometheus.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/output_filters.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/plugins/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/plugins/base.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/plugins/loader.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/plugins/registry.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/routing/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/routing/adaptive.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/routing/auto_router.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/routing/budget.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/routing/capability.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/state/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/state/audit_log.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/state/replay.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/state/request_log.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/state/store.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/state/suggest_rules.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/token_estimation.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/token_estimation_accurate.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/translation/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/translation/anthropic.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/translation/convert.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/coderouter/translation/tool_repair.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/README.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/assets/dashboard-demo.png +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/claude-code-llamacpp-vllm.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/gguf_dl.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/hf-ollama-models.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/install-backends.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/install-backends.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/launcher-quickstart.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/launcher.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/llamacpp-direct.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/llamacpp-direct.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/lmstudio-direct.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/lmstudio-direct.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/backends/verify-ollama-0.23.1.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/concepts/architecture.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/concepts/context-budget.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/concepts/continuous-probing.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/concepts/drift-detection.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/concepts/partial-stitch.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/designs/v1.5-dashboard-mockup.html +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/designs/v1.6-auto-router-verification.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/designs/v1.6-auto-router.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/free-tier-guide.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/free-tier-guide.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/language-tax.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/language-tax.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/security.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/security.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/troubleshooting.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/troubleshooting.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/usage-guide.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/guides/usage-guide.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/low-memory-integration.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/openrouter-roster/CHANGES.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/openrouter-roster/README.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/openrouter-roster/latest.json +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/retrospectives/v0.4.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/retrospectives/v0.5-verify.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/retrospectives/v0.5.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/retrospectives/v0.6.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/retrospectives/v0.7.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/retrospectives/v1.0-verify.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/retrospectives/v1.0.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/start/quickstart.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/start/quickstart.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/start/when-do-i-need-coderouter.en.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/docs/start/when-do-i-need-coderouter.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/.env.example +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/README.md +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers-multiagent.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers.context-budget-test.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers.llamacpp-vllm.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers.nvidia-nim.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers.ollama-auto-custom.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers.ollama-auto.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers.ollama-free-chain.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers.raspberrypi.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/examples/providers.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/scripts/demo_traffic.sh +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/scripts/openrouter_roster_diff.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/scripts/smoke_v2_2.sh +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/scripts/verify-providers.yaml +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/scripts/verify_ollama_0_23.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/scripts/verify_v0_5.sh +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/scripts/verify_v1_0.sh +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/__init__.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/conftest.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_adapter_anthropic.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_audit_log.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_auto_router.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_auto_router_cjk.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_backend_health.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_budget.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_capability.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_capability_degraded_payload.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_capability_registry.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_capability_registry_cache_control.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_capability_tool_choice.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_claude_code_suitability.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_cli.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_cli_stats.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_config.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_config_shim_actions.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_context_budget.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_continuous_probe.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_dashboard_endpoint.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_doctor.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_doctor_apply.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_doctor_cache_probe.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_drift_actions.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_drift_detection.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_drift_detection_integration.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_env_file.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_env_security.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_errors.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_examples_yaml.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback_anthropic.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback_cache_control.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback_cache_observed.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback_cache_strip.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback_misconfig_warn.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback_paid_gate.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback_thinking.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fallback_tool_choice_emulate.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_h1_prometheus_drift.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_h2_h6_translation.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_h3_client_reuse.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_h4_h5_guards.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_h7_probe_restore.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_h8_launcher_auth.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_mA_routing.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_mB_adapters.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_mC_convert.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_mD_logging_metrics.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_mE_config_validation.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_fix_mF_ingress.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_gguf_introspect.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_guards_tool_loop.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_hardware.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_ingress_anthropic.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_ingress_count_tokens.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_ingress_profile.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_language_tax.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_language_tax_integration.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_memory_budget.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_memory_pressure.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_metrics_cache.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_metrics_collector.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_metrics_cost.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_metrics_endpoint.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_metrics_jsonl.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_metrics_prometheus.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_metrics_prometheus_cache.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_openai_compat.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_openrouter_roster_diff.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_output_filters.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_output_filters_adapters.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_partial_stitch.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_plugins_integration.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_plugins_loader.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_plugins_registry.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_reasoning_strip.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_repair_byte_fallback.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_request_log.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_role_normalization.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_routing_adaptive.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_self_healing.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_setup_sh.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_state_store.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_token_estimation.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_token_estimation_accurate.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_tokens_saved_metric.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_tool_repair.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_tool_repair_lenient.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_tool_repair_r4.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_toolrepair_bench.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_translation_anthropic.py +0 -0
- {coderouter_cli-2.7.2 → coderouter_cli-2.7.3}/tests/test_translation_reverse.py +0 -0
|
@@ -6,6 +6,46 @@ versioning follows [SemVer](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [v2.7.3] — 2026-07-05 (Per-request empty-response fallback + L3 bench evidence)
|
|
10
|
+
|
|
11
|
+
Two PRs: **PR #45** (`empty_response_action` — the fallback leg of the
|
|
12
|
+
three-tier tool-call reliability story) and **PR #46** (L3 benchmark
|
|
13
|
+
refresh: model matrix, repairer-version A/B archives, results). Fully
|
|
14
|
+
backward compatible: new knob defaults to `off`, no breaking config
|
|
15
|
+
changes, no new dependencies.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`FallbackChain.empty_response_action: off | warn | fallback`**
|
|
20
|
+
(default `off`). With `fallback`, a 200 response that is *content-empty*
|
|
21
|
+
(no `tool_use`, no non-whitespace text; thinking-only counts as empty) is
|
|
22
|
+
re-dispatched in-flight to the next provider in the chain. Non-streaming
|
|
23
|
+
responses are judged on the finalized object; streaming buffers events
|
|
24
|
+
until the first real content token and discards an unobserved stream.
|
|
25
|
+
Emptiness is judged on content, not `usage.output_tokens` (unreliable on
|
|
26
|
+
some backends). Motivation: gemma4:26b returns blank 200s on
|
|
27
|
+
`no_tool_temptation`-type prompts (20/20 at temperature 0, direct AND via
|
|
28
|
+
router) — no text exists for the repair layer to fix, and the windowed
|
|
29
|
+
drift guard `empty_response_rate` cannot rescue a single blank turn
|
|
30
|
+
in-flight. 21 new tests. (PR #45)
|
|
31
|
+
- **Benchmark refresh**: full L3 model matrix in
|
|
32
|
+
`benchmarks/tool-repair/providers.bench.yaml` (llama3.2/3.1, mistral,
|
|
33
|
+
qwen2.5-coder:1.5b, phi4-mini + originals, `bench-gemma-chain` enabled),
|
|
34
|
+
one-shot matrix runner `bench_l3_p1.sh`, latest live results plus
|
|
35
|
+
repairer-version A/B snapshots under `results/archive-v2.7.{0,1}/`.
|
|
36
|
+
(PR #46)
|
|
37
|
+
|
|
38
|
+
### Results
|
|
39
|
+
|
|
40
|
+
- Live chain validation (M3 Max, temperature 0, 100 requests, zero
|
|
41
|
+
errors): gemma4:26b → qwen3-coder:30b chain **80% → 100%** native —
|
|
42
|
+
all 20 blank turns rescued.
|
|
43
|
+
- Three-tier story now fully measured: repair rescues broken-but-present
|
|
44
|
+
calls (qwen2.5×2 / mistral 0→100, phi4 +60pt), healthy models pass
|
|
45
|
+
through undegraded, and fallback closes what repair cannot touch.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
9
49
|
## [v2.7.2] — 2026-07-05 (R4 tool-call repair: nested-XML / JSON-envelope / call-syntax forms)
|
|
10
50
|
|
|
11
51
|
Single feature PR **#43**, driven by the 2026-07-05 L3 live benchmark
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: coderouter-cli
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.3
|
|
4
4
|
Summary: Local-first, free-first, fallback-built-in LLM router. Claude Code / OpenAI compatible.
|
|
5
5
|
Project-URL: Homepage, https://github.com/zephel01/CodeRouter
|
|
6
6
|
Project-URL: Repository, https://github.com/zephel01/CodeRouter
|
|
@@ -718,6 +718,57 @@ class FallbackChain(BaseModel):
|
|
|
718
718
|
),
|
|
719
719
|
)
|
|
720
720
|
|
|
721
|
+
# --- ⑧ (empty-response): per-request empty-response fallback ------------
|
|
722
|
+
#
|
|
723
|
+
# Some local backends (observed: gemma4:26b on ``no_tool_temptation``
|
|
724
|
+
# prompts) return a 200 with a structurally-valid but *content-empty*
|
|
725
|
+
# Anthropic response — no tool_use and no non-whitespace text — for a
|
|
726
|
+
# fraction of requests. The drift guard's ``empty_response_rate`` is a
|
|
727
|
+
# windowed aggregate (default threshold 0.3, ``min_window_fill`` 6): it
|
|
728
|
+
# promotes/reloads a backend once the *rate* is bad, but cannot rescue a
|
|
729
|
+
# single blank turn in-flight. This knob adds a per-request in-flight
|
|
730
|
+
# fallback that re-dispatches the *same* request to the next provider in
|
|
731
|
+
# the chain the moment an empty response is detected.
|
|
732
|
+
#
|
|
733
|
+
# Design: "empty" is judged on *content*, not usage.output_tokens (which
|
|
734
|
+
# some backends report unreliably). A response is empty when its content
|
|
735
|
+
# list is empty, or every block is either a whitespace-only ``text`` block
|
|
736
|
+
# or a ``thinking`` block — i.e. nothing the client can act on. A single
|
|
737
|
+
# ``tool_use`` block or one non-whitespace ``text`` block makes it non-empty.
|
|
738
|
+
#
|
|
739
|
+
# * ``off`` — no detection, no fallback, no log. Backward-compatible
|
|
740
|
+
# default (byte-for-byte identical to pre-⑧ behavior).
|
|
741
|
+
# * ``warn`` — detect + emit an ``empty-response-detected`` log line
|
|
742
|
+
# only; the empty response is returned unchanged.
|
|
743
|
+
# * ``fallback`` — on an empty response, log ``empty-response-detected``
|
|
744
|
+
# and continue to the next provider (the empty response
|
|
745
|
+
# is *not* recorded as an error). If every provider in
|
|
746
|
+
# the chain returns empty, the last empty response is
|
|
747
|
+
# returned as-is (a 200 blank is a legitimate answer)
|
|
748
|
+
# with ``chain_exhausted=True`` on the log line. On the
|
|
749
|
+
# streaming path, ``fallback`` buffers events until real
|
|
750
|
+
# content is observed, so an empty stream can be swapped
|
|
751
|
+
# to the next provider without the client seeing bytes.
|
|
752
|
+
#
|
|
753
|
+
# Default ``off`` preserves complete backward compatibility; the original
|
|
754
|
+
# request object is never mutated, so a later provider always receives the
|
|
755
|
+
# untouched request.
|
|
756
|
+
empty_response_action: Literal["off", "warn", "fallback"] = Field(
|
|
757
|
+
default="off",
|
|
758
|
+
description=(
|
|
759
|
+
"⑧ (empty-response): action when a provider returns a 200 with "
|
|
760
|
+
"empty content (no tool_use and no non-whitespace text; a "
|
|
761
|
+
"thinking-only response counts as empty). ``off`` (default) does "
|
|
762
|
+
"nothing. ``warn`` emits an ``empty-response-detected`` log only "
|
|
763
|
+
"and returns the empty response. ``fallback`` re-dispatches the "
|
|
764
|
+
"same request to the next provider (empty is not counted as an "
|
|
765
|
+
"error); if the whole chain returns empty, the last empty response "
|
|
766
|
+
"is returned unchanged. Streaming buffers events until real "
|
|
767
|
+
"content appears so empty streams can be swapped provider-side "
|
|
768
|
+
"without the client seeing any bytes."
|
|
769
|
+
),
|
|
770
|
+
)
|
|
771
|
+
|
|
721
772
|
# --- S2 (shim): tool_choice capability gate + emulation -----------------
|
|
722
773
|
#
|
|
723
774
|
# Anthropic clients (Claude Code, SDKs) can pin the model to a specific
|
|
@@ -1372,6 +1372,46 @@ def log_partial_stitch_surfaced(
|
|
|
1372
1372
|
)
|
|
1373
1373
|
|
|
1374
1374
|
|
|
1375
|
+
# ---------------------------------------------------------------------------
|
|
1376
|
+
# ⑧ (empty-response): per-request empty-response fallback log shape
|
|
1377
|
+
#
|
|
1378
|
+
# Fired when a provider returns a 200 with content-empty output (no
|
|
1379
|
+
# tool_use and no non-whitespace text). The single event lane carries the
|
|
1380
|
+
# ``action`` (warn|fallback) that triggered it, whether the empty response
|
|
1381
|
+
# came from the streaming or non-streaming path, and ``chain_exhausted``
|
|
1382
|
+
# — True only when every provider in the chain returned empty and the last
|
|
1383
|
+
# empty response is being returned to the client as-is.
|
|
1384
|
+
# ---------------------------------------------------------------------------
|
|
1385
|
+
|
|
1386
|
+
|
|
1387
|
+
def log_empty_response_detected(
|
|
1388
|
+
logger: logging.Logger,
|
|
1389
|
+
provider: str,
|
|
1390
|
+
*,
|
|
1391
|
+
action: str,
|
|
1392
|
+
stream: bool,
|
|
1393
|
+
chain_exhausted: bool = False,
|
|
1394
|
+
) -> None:
|
|
1395
|
+
"""Emit an ``empty-response-detected`` warn line.
|
|
1396
|
+
|
|
1397
|
+
Fired when ``empty_response_action`` is ``warn`` or ``fallback`` and a
|
|
1398
|
+
provider returns a structurally-valid but content-empty response. The
|
|
1399
|
+
``action`` field records which knob value produced the line; ``stream``
|
|
1400
|
+
distinguishes the SSE path from the non-streaming path; ``chain_exhausted``
|
|
1401
|
+
is True only when the whole chain returned empty and the last empty
|
|
1402
|
+
response is being returned unchanged.
|
|
1403
|
+
"""
|
|
1404
|
+
logger.warning(
|
|
1405
|
+
"empty-response-detected",
|
|
1406
|
+
extra={
|
|
1407
|
+
"provider": provider,
|
|
1408
|
+
"action": action,
|
|
1409
|
+
"stream": stream,
|
|
1410
|
+
"chain_exhausted": chain_exhausted,
|
|
1411
|
+
},
|
|
1412
|
+
)
|
|
1413
|
+
|
|
1414
|
+
|
|
1375
1415
|
# ---------------------------------------------------------------------------
|
|
1376
1416
|
# v2.0-I: Continuous probe log shapes
|
|
1377
1417
|
#
|
|
@@ -52,6 +52,7 @@ Event inventory (dispatch table in :meth:`MetricsCollector._dispatch`)
|
|
|
52
52
|
``drift-promoted`` (v2.0-G) → ``drift_promoted_total``
|
|
53
53
|
``drift-reload-attempted`` → ``drift_reload_total`` / success
|
|
54
54
|
``partial-stitch-surfaced`` → ``partial_stitch_surfaced_total`` (v2.0-H)
|
|
55
|
+
``empty-response-detected`` → ``empty_responses_total`` + per-provider (⑧)
|
|
55
56
|
``probe-completed`` (v2.0-I) → ``probe_total`` / ``probe_success`` / ``probe_failure``
|
|
56
57
|
+ per-provider latency gauge
|
|
57
58
|
``probe-round-completed`` → ``probe_rounds_total`` (v2.0-I)
|
|
@@ -109,6 +110,7 @@ _KNOWN_EVENTS: Final[frozenset[str]] = frozenset(
|
|
|
109
110
|
"drift-promoted",
|
|
110
111
|
"drift-reload-attempted",
|
|
111
112
|
"partial-stitch-surfaced",
|
|
113
|
+
"empty-response-detected",
|
|
112
114
|
"probe-completed",
|
|
113
115
|
"probe-round-completed",
|
|
114
116
|
"probe-capabilities-drift",
|
|
@@ -272,6 +274,13 @@ class MetricsCollector(logging.Handler):
|
|
|
272
274
|
# client instead of a generic error event.
|
|
273
275
|
self._partial_stitch_surfaced_total: int = 0
|
|
274
276
|
|
|
277
|
+
# ⑧ (empty-response): count of per-request empty-response detections
|
|
278
|
+
# (both ``warn`` and ``fallback`` actions). Aggregate + per-provider
|
|
279
|
+
# so a dashboard can spot which backend blanks out. Counts every
|
|
280
|
+
# detection event, including the terminal chain-exhausted one.
|
|
281
|
+
self._empty_responses_total: int = 0
|
|
282
|
+
self._empty_responses_by_provider: Counter[str] = Counter()
|
|
283
|
+
|
|
275
284
|
# v2.0-I: continuous probe counters. Per-provider probe attempts
|
|
276
285
|
# and outcomes, plus a round counter for the dashboard's
|
|
277
286
|
# "probes/min" panel.
|
|
@@ -329,6 +338,7 @@ class MetricsCollector(logging.Handler):
|
|
|
329
338
|
"drift-promoted": self._on_drift_promoted,
|
|
330
339
|
"drift-reload-attempted": self._on_drift_reload_attempted,
|
|
331
340
|
"partial-stitch-surfaced": self._on_partial_stitch_surfaced,
|
|
341
|
+
"empty-response-detected": self._on_empty_response_detected,
|
|
332
342
|
"probe-completed": self._on_probe_completed,
|
|
333
343
|
"probe-round-completed": self._on_probe_round_completed,
|
|
334
344
|
"probe-capabilities-drift": self._on_probe_capabilities_drift,
|
|
@@ -670,6 +680,17 @@ class MetricsCollector(logging.Handler):
|
|
|
670
680
|
self._partial_stitch_surfaced_total += 1
|
|
671
681
|
self._push_recent("partial-stitch-surfaced", extras, record)
|
|
672
682
|
|
|
683
|
+
def _on_empty_response_detected(
|
|
684
|
+
self, extras: dict[str, Any], record: logging.LogRecord
|
|
685
|
+
) -> None:
|
|
686
|
+
# ⑧ (empty-response): a content-empty 200 was detected under a
|
|
687
|
+
# ``warn`` / ``fallback`` action.
|
|
688
|
+
self._empty_responses_total += 1
|
|
689
|
+
provider = _str(extras.get("provider"))
|
|
690
|
+
if provider:
|
|
691
|
+
self._empty_responses_by_provider[provider] += 1
|
|
692
|
+
self._push_recent("empty-response-detected", extras, record)
|
|
693
|
+
|
|
673
694
|
def _on_probe_completed(
|
|
674
695
|
self, extras: dict[str, Any], record: logging.LogRecord
|
|
675
696
|
) -> None:
|
|
@@ -888,6 +909,11 @@ class MetricsCollector(logging.Handler):
|
|
|
888
909
|
"drift_reload_success_total": self._drift_reload_success_total,
|
|
889
910
|
# v2.0-H (L6): partial stitch surfaced.
|
|
890
911
|
"partial_stitch_surfaced_total": self._partial_stitch_surfaced_total,
|
|
912
|
+
# ⑧ (empty-response): per-request empty-response fallback.
|
|
913
|
+
"empty_responses_total": self._empty_responses_total,
|
|
914
|
+
"empty_responses_by_provider": dict(
|
|
915
|
+
self._empty_responses_by_provider
|
|
916
|
+
),
|
|
891
917
|
# v2.0-I: continuous probe counters.
|
|
892
918
|
"probe_total": dict(self._probe_total),
|
|
893
919
|
"probe_success": dict(self._probe_success),
|
|
@@ -1042,6 +1068,9 @@ class MetricsCollector(logging.Handler):
|
|
|
1042
1068
|
self._tokens_saved_by_mechanism.clear()
|
|
1043
1069
|
# v2.0-H (L6)
|
|
1044
1070
|
self._partial_stitch_surfaced_total = 0
|
|
1071
|
+
# ⑧ (empty-response)
|
|
1072
|
+
self._empty_responses_total = 0
|
|
1073
|
+
self._empty_responses_by_provider.clear()
|
|
1045
1074
|
# v2.0-I
|
|
1046
1075
|
self._probe_total.clear()
|
|
1047
1076
|
self._probe_success.clear()
|
|
@@ -76,6 +76,7 @@ from coderouter.logging import (
|
|
|
76
76
|
log_chain_memory_pressure_blocked,
|
|
77
77
|
log_chain_paid_gate_blocked,
|
|
78
78
|
log_demote_unhealthy_provider,
|
|
79
|
+
log_empty_response_detected,
|
|
79
80
|
log_memory_pressure_detected,
|
|
80
81
|
log_skip_budget_exceeded,
|
|
81
82
|
log_skip_memory_pressure,
|
|
@@ -973,6 +974,82 @@ def _warn_if_uniform_auth_failure(errors: list[AdapterError], *, profile: str) -
|
|
|
973
974
|
)
|
|
974
975
|
|
|
975
976
|
|
|
977
|
+
# ---------------------------------------------------------------------------
|
|
978
|
+
# ⑧ (empty-response): content-based emptiness judgement + stream buffering
|
|
979
|
+
# ---------------------------------------------------------------------------
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
def _block_field(block: Any, key: str) -> Any:
|
|
983
|
+
"""Read ``key`` from a content block whether it is a dict or a model.
|
|
984
|
+
|
|
985
|
+
Anthropic content blocks reach the engine as plain dicts (openai_compat
|
|
986
|
+
translation, most test fakes) or as pydantic-ish objects (native
|
|
987
|
+
passthrough). This mirrors the accessor pattern already used by the
|
|
988
|
+
drift fingerprint at the success-path tail.
|
|
989
|
+
"""
|
|
990
|
+
if isinstance(block, dict):
|
|
991
|
+
return block.get(key)
|
|
992
|
+
return getattr(block, key, None)
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
def _anthropic_response_is_empty(resp: AnthropicResponse) -> bool:
|
|
996
|
+
"""Return True when ``resp`` carries no client-actionable content.
|
|
997
|
+
|
|
998
|
+
"Empty" is judged on content, never on ``usage.output_tokens`` (some
|
|
999
|
+
backends report that unreliably). A response is empty when:
|
|
1000
|
+
- its ``content`` list is empty / falsy, or
|
|
1001
|
+
- every block is either a whitespace-only ``text`` block or a
|
|
1002
|
+
``thinking`` block.
|
|
1003
|
+
|
|
1004
|
+
A single ``tool_use`` block, or one ``text`` block with any
|
|
1005
|
+
non-whitespace character, makes the response non-empty. Unknown block
|
|
1006
|
+
types are treated conservatively as *content* (non-empty) so a novel
|
|
1007
|
+
actionable block is never silently swallowed.
|
|
1008
|
+
"""
|
|
1009
|
+
content = getattr(resp, "content", None)
|
|
1010
|
+
if not content:
|
|
1011
|
+
return True
|
|
1012
|
+
for block in content:
|
|
1013
|
+
btype = _block_field(block, "type")
|
|
1014
|
+
if btype == "text":
|
|
1015
|
+
text = _block_field(block, "text") or ""
|
|
1016
|
+
if text.strip():
|
|
1017
|
+
return False
|
|
1018
|
+
# whitespace-only text → keep scanning
|
|
1019
|
+
continue
|
|
1020
|
+
if btype == "thinking":
|
|
1021
|
+
# thinking-only carries nothing the client can act on
|
|
1022
|
+
continue
|
|
1023
|
+
# tool_use or any other (unknown → conservatively non-empty) block
|
|
1024
|
+
return False
|
|
1025
|
+
return True
|
|
1026
|
+
|
|
1027
|
+
|
|
1028
|
+
def _stream_event_is_real_content(event: AnthropicStreamEvent) -> bool:
|
|
1029
|
+
"""Return True when ``event`` is the first byte of actionable content.
|
|
1030
|
+
|
|
1031
|
+
Real content is either a ``content_block_start`` opening a ``tool_use``
|
|
1032
|
+
block, or a ``content_block_delta`` carrying a non-whitespace text
|
|
1033
|
+
delta. ``message_start`` / ``ping`` / empty-text openers do not count —
|
|
1034
|
+
they are the buffered preamble that an empty stream also emits.
|
|
1035
|
+
"""
|
|
1036
|
+
data = getattr(event, "data", None) or {}
|
|
1037
|
+
etype = data.get("type") if isinstance(data, dict) else None
|
|
1038
|
+
if etype == "content_block_start":
|
|
1039
|
+
block = data.get("content_block") or {}
|
|
1040
|
+
return isinstance(block, dict) and block.get("type") == "tool_use"
|
|
1041
|
+
if etype == "content_block_delta":
|
|
1042
|
+
delta = data.get("delta") or {}
|
|
1043
|
+
if isinstance(delta, dict):
|
|
1044
|
+
# text_delta with non-whitespace text is real content;
|
|
1045
|
+
# input_json_delta (tool args) is real content too.
|
|
1046
|
+
if delta.get("type") == "text_delta":
|
|
1047
|
+
return bool((delta.get("text") or "").strip())
|
|
1048
|
+
if delta.get("type") == "input_json_delta":
|
|
1049
|
+
return True
|
|
1050
|
+
return False
|
|
1051
|
+
|
|
1052
|
+
|
|
976
1053
|
class FallbackEngine:
|
|
977
1054
|
"""Sequential fallback router — the core of CodeRouter.
|
|
978
1055
|
|
|
@@ -1717,6 +1794,20 @@ class FallbackEngine:
|
|
|
1717
1794
|
getattr(profile, "cache_control_action", "off"),
|
|
1718
1795
|
)
|
|
1719
1796
|
|
|
1797
|
+
def _resolve_empty_response_action(self, profile_name: str | None) -> str:
|
|
1798
|
+
"""⑧ (empty-response): resolve ``empty_response_action`` for a profile.
|
|
1799
|
+
|
|
1800
|
+
Defaults to ``off`` so a missing / stub profile (e.g. a
|
|
1801
|
+
``__new__``-constructed test engine) yields the backward-compatible
|
|
1802
|
+
no-op. Resolved once at the top of each Anthropic entry point.
|
|
1803
|
+
"""
|
|
1804
|
+
chosen = profile_name or self.config.default_profile
|
|
1805
|
+
try:
|
|
1806
|
+
profile = self.config.profile_by_name(chosen)
|
|
1807
|
+
except (KeyError, ValueError):
|
|
1808
|
+
return "off"
|
|
1809
|
+
return getattr(profile, "empty_response_action", "off")
|
|
1810
|
+
|
|
1720
1811
|
def _resolve_chain(self, profile_name: str | None) -> list[BaseAdapter]:
|
|
1721
1812
|
"""Return the list of adapters to try, in order, for this profile.
|
|
1722
1813
|
|
|
@@ -2431,6 +2522,11 @@ class FallbackEngine:
|
|
|
2431
2522
|
tool_choice_action, cache_control_action = self._resolve_shim_actions(
|
|
2432
2523
|
request.profile
|
|
2433
2524
|
)
|
|
2525
|
+
# ⑧ (empty-response): resolve the per-request empty-response action
|
|
2526
|
+
# once. ``last_empty_resp`` holds the most recent content-empty 200
|
|
2527
|
+
# under ``fallback`` so a fully-empty chain returns it verbatim.
|
|
2528
|
+
empty_response_action = self._resolve_empty_response_action(request.profile)
|
|
2529
|
+
last_empty_resp: AnthropicResponse | None = None
|
|
2434
2530
|
|
|
2435
2531
|
for adapter, will_degrade in chain:
|
|
2436
2532
|
is_native = isinstance(adapter, AnthropicAdapter)
|
|
@@ -2585,6 +2681,26 @@ class FallbackEngine:
|
|
|
2585
2681
|
stream=False,
|
|
2586
2682
|
response_fingerprint=_fp(_fp_text) if _fp_text else None,
|
|
2587
2683
|
)
|
|
2684
|
+
# ⑧ (empty-response): per-request empty-response handling. Runs
|
|
2685
|
+
# after the drift observation above (which still gets the real
|
|
2686
|
+
# output_tokens=0 signal for the windowed empty_response_rate)
|
|
2687
|
+
# but before the cache-observed / observer fanout, so a
|
|
2688
|
+
# ``fallback`` swap does not emit a "completed" line for a
|
|
2689
|
+
# response the client never sees.
|
|
2690
|
+
if empty_response_action != "off" and _anthropic_response_is_empty(resp):
|
|
2691
|
+
if empty_response_action == "fallback":
|
|
2692
|
+
# Remember this empty response so a fully-empty chain can
|
|
2693
|
+
# return it verbatim, then try the next provider. Not
|
|
2694
|
+
# recorded in ``errors`` — a 200 blank is not a failure.
|
|
2695
|
+
last_empty_resp = resp
|
|
2696
|
+
log_empty_response_detected(
|
|
2697
|
+
logger, adapter.name, action="fallback", stream=False
|
|
2698
|
+
)
|
|
2699
|
+
continue
|
|
2700
|
+
# ``warn``: log only; fall through and return the empty resp.
|
|
2701
|
+
log_empty_response_detected(
|
|
2702
|
+
logger, adapter.name, action="warn", stream=False
|
|
2703
|
+
)
|
|
2588
2704
|
# v1.9-A: pair every successful Anthropic response with a
|
|
2589
2705
|
# cache-observed log line. Native Anthropic / LM Studio
|
|
2590
2706
|
# /v1/messages report cache_read_input_tokens /
|
|
@@ -2625,6 +2741,20 @@ class FallbackEngine:
|
|
|
2625
2741
|
)
|
|
2626
2742
|
return resp
|
|
2627
2743
|
|
|
2744
|
+
# ⑧ (empty-response): the chain is exhausted. Under ``fallback``,
|
|
2745
|
+
# if every provider that answered returned an empty 200, return the
|
|
2746
|
+
# last empty response verbatim (a 200 blank is a legitimate answer)
|
|
2747
|
+
# rather than raising — errors is empty in that case anyway.
|
|
2748
|
+
if last_empty_resp is not None:
|
|
2749
|
+
log_empty_response_detected(
|
|
2750
|
+
logger,
|
|
2751
|
+
last_empty_resp.coderouter_provider or "unknown",
|
|
2752
|
+
action="fallback",
|
|
2753
|
+
stream=False,
|
|
2754
|
+
chain_exhausted=True,
|
|
2755
|
+
)
|
|
2756
|
+
return last_empty_resp
|
|
2757
|
+
|
|
2628
2758
|
profile = request.profile or self.config.default_profile
|
|
2629
2759
|
_warn_if_uniform_auth_failure(errors, profile=profile)
|
|
2630
2760
|
raise NoProvidersAvailableError(profile=profile, errors=errors)
|
|
@@ -2676,6 +2806,15 @@ class FallbackEngine:
|
|
|
2676
2806
|
tool_choice_action, cache_control_action = self._resolve_shim_actions(
|
|
2677
2807
|
request.profile
|
|
2678
2808
|
)
|
|
2809
|
+
# ⑧ (empty-response): resolve the per-request empty-response action.
|
|
2810
|
+
# Only ``fallback`` changes the streaming path (it buffers events
|
|
2811
|
+
# until real content appears); ``off`` / ``warn`` stream unchanged.
|
|
2812
|
+
# ``last_empty_stream_buffer`` holds the buffered preamble of the
|
|
2813
|
+
# most recent empty stream so a fully-empty chain can flush it and
|
|
2814
|
+
# terminate normally rather than raising.
|
|
2815
|
+
empty_response_action = self._resolve_empty_response_action(request.profile)
|
|
2816
|
+
empty_fallback = empty_response_action == "fallback"
|
|
2817
|
+
last_empty_stream_buffer: list[AnthropicStreamEvent] | None = None
|
|
2679
2818
|
|
|
2680
2819
|
for adapter, will_degrade in chain:
|
|
2681
2820
|
is_native = isinstance(adapter, AnthropicAdapter)
|
|
@@ -2828,15 +2967,59 @@ class FallbackEngine:
|
|
|
2828
2967
|
self._observe_provider_success(
|
|
2829
2968
|
adapter.name, profile=request.profile
|
|
2830
2969
|
)
|
|
2831
|
-
|
|
2832
|
-
|
|
2970
|
+
# ⑧ (empty-response): under ``fallback`` we withhold the opening
|
|
2971
|
+
# events (message_start / empty content_block_start / ping) from
|
|
2972
|
+
# the client until the *first real content* event is observed.
|
|
2973
|
+
# Because no bytes have reached the client, an empty stream can
|
|
2974
|
+
# still be swapped for the next provider. ``off`` / ``warn`` keep
|
|
2975
|
+
# the legacy immediate-yield behavior (byte-for-byte unchanged).
|
|
2976
|
+
#
|
|
2977
|
+
# ``content_started`` flips True the moment real content is seen
|
|
2978
|
+
# (or immediately, when the action is not ``fallback``); from
|
|
2979
|
+
# then on events pass straight through and the mid-stream guard
|
|
2980
|
+
# is live exactly as before.
|
|
2981
|
+
content_started = not empty_fallback
|
|
2982
|
+
buffer: list[AnthropicStreamEvent] = []
|
|
2833
2983
|
# Mid-stream guard identical to stream() — any error after the
|
|
2834
|
-
# first event is terminal.
|
|
2984
|
+
# first *forwarded* event is terminal.
|
|
2835
2985
|
try:
|
|
2836
|
-
|
|
2986
|
+
# Seed the loop with the already-fetched ``first`` event,
|
|
2987
|
+
# then drain the rest of the iterator.
|
|
2988
|
+
pending = first
|
|
2989
|
+
iterator = event_iter.__aiter__()
|
|
2990
|
+
while True:
|
|
2991
|
+
ev = pending
|
|
2837
2992
|
acc.observe(ev)
|
|
2838
|
-
|
|
2993
|
+
if content_started:
|
|
2994
|
+
yield ev
|
|
2995
|
+
else:
|
|
2996
|
+
buffer.append(ev)
|
|
2997
|
+
if _stream_event_is_real_content(ev):
|
|
2998
|
+
# Real content arrived — flush the withheld
|
|
2999
|
+
# preamble in order, then switch to passthrough.
|
|
3000
|
+
content_started = True
|
|
3001
|
+
for buffered_ev in buffer:
|
|
3002
|
+
yield buffered_ev
|
|
3003
|
+
buffer = []
|
|
3004
|
+
try:
|
|
3005
|
+
pending = await iterator.__anext__()
|
|
3006
|
+
except StopAsyncIteration:
|
|
3007
|
+
break
|
|
2839
3008
|
except AdapterError as exc:
|
|
3009
|
+
if not content_started:
|
|
3010
|
+
# Empty-stream failure before any real content under
|
|
3011
|
+
# ``fallback``: nothing reached the client, so treat it
|
|
3012
|
+
# like an empty response and try the next provider. Do
|
|
3013
|
+
# NOT raise MidStreamError (that would surface to the
|
|
3014
|
+
# client). Record the error-only observation for adaptive.
|
|
3015
|
+
self._adaptive.record_attempt(
|
|
3016
|
+
adapter.name, latency_ms=None, success=False
|
|
3017
|
+
)
|
|
3018
|
+
log_empty_response_detected(
|
|
3019
|
+
logger, adapter.name, action="fallback", stream=True
|
|
3020
|
+
)
|
|
3021
|
+
last_empty_stream_buffer = buffer
|
|
3022
|
+
continue
|
|
2840
3023
|
# M2: mid-stream failure — record an error-only
|
|
2841
3024
|
# observation (no latency; first-event success already
|
|
2842
3025
|
# recorded) so adaptive error rate reflects the breakage.
|
|
@@ -2868,6 +3051,17 @@ class FallbackEngine:
|
|
|
2868
3051
|
raise MidStreamError(
|
|
2869
3052
|
adapter.name, exc, partial_content=acc.partial_content
|
|
2870
3053
|
) from exc
|
|
3054
|
+
# ⑧ (empty-response): the stream ended cleanly but no real
|
|
3055
|
+
# content was ever observed under ``fallback`` — the preamble is
|
|
3056
|
+
# still buffered (never sent). Treat as an empty response: keep
|
|
3057
|
+
# the buffer for a possible chain-exhausted flush and try the
|
|
3058
|
+
# next provider.
|
|
3059
|
+
if empty_fallback and not content_started:
|
|
3060
|
+
log_empty_response_detected(
|
|
3061
|
+
logger, adapter.name, action="fallback", stream=True
|
|
3062
|
+
)
|
|
3063
|
+
last_empty_stream_buffer = buffer
|
|
3064
|
+
continue
|
|
2871
3065
|
# v2.0-G (L4): drift detection observation (stream success).
|
|
2872
3066
|
# P1-4: compute response fingerprint for goal_progress_stall.
|
|
2873
3067
|
_stream_fp_text = " ".join(
|
|
@@ -2923,6 +3117,23 @@ class FallbackEngine:
|
|
|
2923
3117
|
)
|
|
2924
3118
|
return
|
|
2925
3119
|
|
|
3120
|
+
# ⑧ (empty-response): the chain is exhausted under ``fallback`` and
|
|
3121
|
+
# every provider produced an empty stream. Flush the last buffered
|
|
3122
|
+
# (empty) preamble so the client gets a well-formed, terminating SSE
|
|
3123
|
+
# sequence (message_start … message_stop) instead of an error — a
|
|
3124
|
+
# 200 blank is a legitimate answer. errors is empty in that case.
|
|
3125
|
+
if last_empty_stream_buffer is not None:
|
|
3126
|
+
log_empty_response_detected(
|
|
3127
|
+
logger,
|
|
3128
|
+
"unknown",
|
|
3129
|
+
action="fallback",
|
|
3130
|
+
stream=True,
|
|
3131
|
+
chain_exhausted=True,
|
|
3132
|
+
)
|
|
3133
|
+
for buffered_ev in last_empty_stream_buffer:
|
|
3134
|
+
yield buffered_ev
|
|
3135
|
+
return
|
|
3136
|
+
|
|
2926
3137
|
profile = request.profile or self.config.default_profile
|
|
2927
3138
|
_warn_if_uniform_auth_failure(errors, profile=profile)
|
|
2928
3139
|
raise NoProvidersAvailableError(profile=profile, errors=errors)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# in plan.md §11.B; once granted, this name will become an alias and
|
|
12
12
|
# `coderouter` will become the canonical distribution name.
|
|
13
13
|
name = "coderouter-cli"
|
|
14
|
-
version = "2.7.
|
|
14
|
+
version = "2.7.3"
|
|
15
15
|
description = "Local-first, free-first, fallback-built-in LLM router. Claude Code / OpenAI compatible."
|
|
16
16
|
readme = "README.md"
|
|
17
17
|
requires-python = ">=3.12"
|