Treat app gateway target as explicit routing
This commit is contained in:
parent
3f964710f5
commit
caf541995e
@ -18,10 +18,14 @@ func (e *DefaultRoutingEngine) Resolve(ctx context.Context, params map[string]an
|
||||
if len(routingParams) == 0 {
|
||||
routingParams = map[string]any{}
|
||||
}
|
||||
routingMode := strings.TrimSpace(shared.StringArg(routingParams, "routingMode", "implicit"))
|
||||
explicitExecutionTarget := strings.TrimSpace(shared.StringArg(routingParams, "explicitExecutionTarget", ""))
|
||||
if explicitExecutionTarget == "" {
|
||||
explicitExecutionTarget = strings.TrimSpace(shared.StringArg(params, "executionTarget", ""))
|
||||
}
|
||||
if explicitExecutionTarget != "" {
|
||||
routingMode = router.RoutingModeExplicit
|
||||
}
|
||||
preferredGatewayProviderID := strings.TrimSpace(shared.StringArg(routingParams, "preferredGatewayProviderId", ""))
|
||||
if preferredGatewayProviderID == "" {
|
||||
preferredGatewayProviderID = strings.TrimSpace(shared.StringArg(params, "gatewayProviderId", ""))
|
||||
@ -38,7 +42,7 @@ func (e *DefaultRoutingEngine) Resolve(ctx context.Context, params map[string]an
|
||||
res := resolver.Resolve(router.Request{
|
||||
Prompt: strings.TrimSpace(shared.StringArg(params, "taskPrompt", "")),
|
||||
WorkingDirectory: strings.TrimSpace(shared.StringArg(params, "workingDirectory", "")),
|
||||
RoutingMode: strings.TrimSpace(shared.StringArg(routingParams, "routingMode", "implicit")),
|
||||
RoutingMode: routingMode,
|
||||
PreferredGatewayProviderID: preferredGatewayProviderID,
|
||||
ExplicitExecutionTarget: explicitExecutionTarget,
|
||||
ExplicitProviderID: strings.TrimSpace(shared.StringArg(routingParams, "explicitProviderId", "")),
|
||||
|
||||
@ -222,19 +222,35 @@ func TestHandleRoutingResolveCoversNineScenarioBuckets(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHandleRoutingResolveAcceptsTopLevelGatewayContract(t *testing.T) {
|
||||
result := handleRoutingResolve(map[string]any{
|
||||
server := NewServer()
|
||||
server.mu.Lock()
|
||||
server.providerOrder = []string{"codex"}
|
||||
server.providers = map[string]ProviderCompat{
|
||||
"codex": newProviderCompat(syncedProvider{
|
||||
ProviderID: "codex",
|
||||
Label: "Codex",
|
||||
Endpoint: "ws://127.0.0.1:9001/acp",
|
||||
Enabled: true,
|
||||
}),
|
||||
}
|
||||
server.mu.Unlock()
|
||||
|
||||
res, err := server.routingEngine.Resolve(context.Background(), map[string]any{
|
||||
"taskPrompt": "openclaw gateway task",
|
||||
"executionTarget": "gateway",
|
||||
"gatewayProviderId": "openclaw",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("resolve routing: %v", err)
|
||||
}
|
||||
|
||||
if got := result["resolvedExecutionTarget"]; got != "gateway" {
|
||||
if got := res.TargetID; got != "gateway" {
|
||||
t.Fatalf("expected gateway execution target, got %#v", got)
|
||||
}
|
||||
if got := result["resolvedGatewayProviderId"]; got != "openclaw" {
|
||||
if got := res.GatewayProviderID; got != "openclaw" {
|
||||
t.Fatalf("expected openclaw gateway provider, got %#v", got)
|
||||
}
|
||||
if got := result["resolvedProviderId"]; got != "" {
|
||||
if got := res.ProviderID; got != "" {
|
||||
t.Fatalf("expected no single-agent provider for gateway, got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user