dispatch_food_truck per-dispatch backend override (heterogeneous routing R1)#4182
Merged
Trecek merged 7 commits intoJul 5, 2026
Conversation
Adds an optional `backend` parameter to the `dispatch_food_truck` MCP tool that selects which coding-agent backend executes the dispatched child session. When omitted, behavior is identical to today (uses ctx.backend). When supplied, the per-dispatch backend is used for capability gating, command building, pre-launch validation, recipe admission control, session-log resolution, and record persistence. Key changes: - FleetErrorCode.FLEET_INVALID_BACKEND for unknown backend names - DispatchRecord.backend_name field (in _RETRY_IDENTITY_FIELDS) - dispatch_food_truck executor resolves + threads dispatch_backend - execute_dispatch / _run_dispatch accept dispatch_backend parameter - MCP tool validates backend against BACKEND_REGISTRY before dispatch Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ckend override - Move resolve_backend_override to server/_misc.py (allowed import layer for tools) - Hoist BACKEND_REGISTRY import to module level to satisfy IL-3 deferred import rules - Fix mock backend .name attribute causing JSON serialization failures - Fix mock project_log_dir returning string instead of Path - Update test assertions to match actual dispatch behavior - Bump headless/__init__.py line budget to 510 - Add fleet cascade map entries for new test file Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…escing Aligns with fleet/_api.py pattern that uses `is not None` guard instead of falsy `or` coalescing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The `as BACKEND_REGISTRY` form is only needed for public re-exports; this import is consumed locally within _misc.py. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ackend guard The assert at L432 could be stripped under python -O, leaving a silent None dereference. An explicit if-raise provides deterministic behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… guard The previous commit changed the assert to an explicit RuntimeError raise; the test must match the new exception type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…kend enum Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Jul 5, 2026
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
Add an optional
backendparameter to thedispatch_food_truckMCP tool that selects which coding-agent backend executes the dispatched child session. When omitted, behavior is byte-for-byte identical to today (usesctx.backend). When supplied, the per-dispatch backend is used for: capability gating (food_truck_capable), command building (build_food_truck_cmd), pre-launch validation (ensure_pre_launch), recipe admission control (capability overrides,backend-incompatible-skillrule,effective_backend_map), session-log resolution, and record persistence. TheDispatchRecordgains abackend_namefield so downstream consumers (reset, diagnostics, session-log lookup) resolve against the correct backend. The field is added to_RETRY_IDENTITY_FIELDSso retried dispatches preserve the backend override.The implementation follows the existing
run_headless_corecall-local override pattern:ctx.backendis never mutated; a resolvedCodingAgentBackendinstance is threaded through the dispatch path as a function argument.Requirements
REQ-HBR-001: The
dispatch_food_truckMCP tool (server/tools/tools_fleet_dispatch.py) must accept an optionalbackendparameter whose accepted values are the names registered inBACKEND_REGISTRY("claude-code","codex").REQ-HBR-002: When the
backendparameter is omitted, dispatch behavior must be byte-for-byte identical to the currentctx.backendpath — zero behavior change for existing single-backend flows.REQ-HBR-003: The child session command must be built via the per-dispatch backend's
build_food_truck_cmd, with backend-correct env injection (AUTOSKILLIT_AGENT_BACKEND__BACKEND,AUTOSKILLIT_AGENT_BACKEND,AUTOSKILLIT_MCP_CLIENT_BACKEND) so the child process resolves the per-dispatch backend at boot.REQ-HBR-004:
ensure_pre_launch()must be invoked on the per-dispatch backend before spawn (e.g., Codex MCP registration inconfig.toml).REQ-HBR-005: The
food_truck_capablecapability gate must be evaluated against the per-dispatch backend, not the kitchen backend.REQ-HBR-006: Recipe admission control and capability overrides must be computed against the per-dispatch backend:
_provider_aware_capability_overrides, thebackend_supports_git_writeingredient,_compute_effective_backend_map, and thebackend-incompatible-skillvalidation rule (server/tools/_auto_overrides.py,recipe/rules/rules_backend_compat.py).REQ-HBR-007: Per-dispatch backend selection must compose with existing provider profiles (e.g., a MiniMax implement-step provider override via
ANTHROPIC_BASE_URL) and with the R0 capability-driven auto-route (#4176) inside the child session — existing provider recipe overrides must behave identically.REQ-HBR-008: The
DispatchRecordmust persist which backend the dispatch ran on, so thatreset_dispatch, diagnostics, and session-log lookup (Channel B for Claude Code vsCodexSessionLocatorfor Codex) resolve against the correct backend.REQ-HBR-009: Any
BackendCapabilitiesfield addition required by this work must be forward-declared with a tracking entry in_FORWARD_DECLAREDintest_capability_consumption.py(frozen-dataclass constraint noted in the forward-obligations doc).Closes #4179
Implementation Plan
Plan file:
.autoskillit/temp/make-plan/dispatch_food_truck_per_dispatch_backend_override_plan_2026-07-04_152400.md🤖 Generated with Claude Code via AutoSkillit
Token Usage Summary
* Step used a non-Anthropic provider; caching behavior may differ.
Token Efficiency
Model Usage Breakdown