Skip to content

Commit dc5a59e

Browse files
jamesonicsclaude
andcommitted
[feat][evaluation] support a2a_agent and custom_agent eval target types on OpenAPI experiment-create path
The web link already supports A2A Agent (a2a_agent, type=9) and the in-house long-connection agent (custom_agent, type=10), and the execution operators are registered downstream. The OpenAPI experiment-create path, however, rejected these two types: mapOpenAPIEvalTargetType only cased 6 types, so a2a_agent / custom_agent fell through to default and were blocked both by the up-front SubmitExperimentOApi validation and by the convertor. This wires the OpenAPI path to the same service layer the web link uses: - mapOpenAPIEvalTargetType: add cases a2a_agent -> A2AAgent, custom_agent -> CustomAgent. - supportedOpenAPIEvalTargetTypes: add both so the up-front validation and the error message stay in sync. No IDL change (the OpenAPI string enums and EvalTargetContent sub-fields already exist) and no operator change (already registered in the commercial DI). Meego: 7337555141 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2011284 commit dc5a59e

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎backend/modules/evaluation/application/convertor/experiment/openapi.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ var supportedOpenAPIEvalTargetTypes = []openapiEvalTarget.EvalTargetType{
226226
openapiEvalTarget.EvalTargetTypeCozeWorkflow,
227227
openapiEvalTarget.EvalTargetTypeVolcengineAgent,
228228
openapiEvalTarget.EvalTargetTypeCustomRPCServer,
229+
openapiEvalTarget.EvalTargetTypeA2Agent,
230+
openapiEvalTarget.EvalTargetTypeCustomAgent,
229231
}
230232

231233
func supportedOpenAPIEvalTargetTypesString() string {
@@ -260,6 +262,10 @@ func mapOpenAPIEvalTargetType(openapiType openapiEvalTarget.EvalTargetType) (dom
260262
return domaindoEvalTarget.EvalTargetType_VolcengineAgent, nil
261263
case openapiEvalTarget.EvalTargetTypeCustomRPCServer:
262264
return domaindoEvalTarget.EvalTargetType_CustomRPCServer, nil
265+
case openapiEvalTarget.EvalTargetTypeA2Agent:
266+
return domaindoEvalTarget.EvalTargetType_A2AAgent, nil
267+
case openapiEvalTarget.EvalTargetTypeCustomAgent:
268+
return domaindoEvalTarget.EvalTargetType_CustomAgent, nil
263269
default:
264270
return 0, fmt.Errorf("unsupported eval target type: %s. supported: [%s]", openapiType, supportedOpenAPIEvalTargetTypesString())
265271
}

‎backend/modules/evaluation/application/convertor/experiment/openapi_test.go‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ func TestMapOpenAPIEvalTargetType(t *testing.T) {
278278
{"workflow", openapiEvalTarget.EvalTargetTypeCozeWorkflow, domaindoEvalTarget.EvalTargetType_CozeWorkflow, false},
279279
{"volcengine", openapiEvalTarget.EvalTargetTypeVolcengineAgent, domaindoEvalTarget.EvalTargetType_VolcengineAgent, false},
280280
{"rpc", openapiEvalTarget.EvalTargetTypeCustomRPCServer, domaindoEvalTarget.EvalTargetType_CustomRPCServer, false},
281+
{"a2a_agent", openapiEvalTarget.EvalTargetTypeA2Agent, domaindoEvalTarget.EvalTargetType_A2AAgent, false},
282+
{"custom_agent", openapiEvalTarget.EvalTargetTypeCustomAgent, domaindoEvalTarget.EvalTargetType_CustomAgent, false},
281283
{"invalid", openapiEvalTarget.EvalTargetType("invalid"), 0, true},
282284
}
283285

@@ -2975,6 +2977,55 @@ func TestOpenAPICreateEvalTargetParamDTO2Domain_WithClusterAndAgentConnection(t
29752977
}
29762978
}
29772979

2980+
// TestOpenAPICreateEvalTargetParamDTO2Domain_AgentTypes verifies the OpenAPI
2981+
// experiment-create path accepts the two agent eval target types that the web
2982+
// link already supports: a2a_agent (type=9) and custom_agent (type=10, the
2983+
// in-house long-connection agent). The convertor must translate the string
2984+
// type to the int domain enum and carry the agent connection info.
2985+
func TestOpenAPICreateEvalTargetParamDTO2Domain_AgentTypes(t *testing.T) {
2986+
t.Parallel()
2987+
2988+
// custom_agent (长链接 Agent): submitted with cluster + agent_connection.
2989+
customAgentType := openapiEvalTarget.EvalTargetTypeCustomAgent
2990+
customAgentParam := &openapi.SubmitExperimentEvalTargetParam{
2991+
SourceTargetID: gptr.Of("custom-agent-1"),
2992+
EvalTargetType: &customAgentType,
2993+
Cluster: gptr.Of("cluster-loong"),
2994+
AgentConnection: &openapiEvalTarget.AgentConnection{
2995+
Psm: gptr.Of("agent.psm"),
2996+
FrontierInfo: &openapiEvalTarget.FrontierInfo{
2997+
AppID: gptr.Of(int64(100)),
2998+
},
2999+
},
3000+
}
3001+
convertedCustom, errCustom := OpenAPICreateEvalTargetParamDTO2Domain(customAgentParam)
3002+
assert.NoError(t, errCustom)
3003+
if assert.NotNil(t, convertedCustom) {
3004+
assert.Equal(t, domaindoEvalTarget.EvalTargetType_CustomAgent, gptr.Indirect(convertedCustom.EvalTargetType))
3005+
assert.Equal(t, gptr.Of("cluster-loong"), convertedCustom.Cluster)
3006+
if assert.NotNil(t, convertedCustom.AgentConnection) {
3007+
assert.Equal(t, gptr.Of("agent.psm"), convertedCustom.AgentConnection.Psm)
3008+
}
3009+
}
3010+
3011+
// a2a_agent: referenced by source_target_id (pre-registered Application).
3012+
a2aType := openapiEvalTarget.EvalTargetTypeA2Agent
3013+
a2aParam := &openapi.SubmitExperimentEvalTargetParam{
3014+
SourceTargetID: gptr.Of("a2a-agent-1"),
3015+
EvalTargetType: &a2aType,
3016+
}
3017+
convertedA2A, errA2A := OpenAPICreateEvalTargetParamDTO2Domain(a2aParam)
3018+
assert.NoError(t, errA2A)
3019+
if assert.NotNil(t, convertedA2A) {
3020+
assert.Equal(t, domaindoEvalTarget.EvalTargetType_A2AAgent, gptr.Indirect(convertedA2A.EvalTargetType))
3021+
assert.Equal(t, "a2a-agent-1", gptr.Indirect(convertedA2A.SourceTargetID))
3022+
}
3023+
3024+
// Both agent types must pass the up-front validation gate.
3025+
assert.True(t, IsSupportedOpenAPIEvalTargetType(openapiEvalTarget.EvalTargetTypeA2Agent))
3026+
assert.True(t, IsSupportedOpenAPIEvalTargetType(openapiEvalTarget.EvalTargetTypeCustomAgent))
3027+
}
3028+
29783029
func TestOpenapiAgentConnectionDTO2Domain_Nil(t *testing.T) {
29793030
t.Parallel()
29803031
assert.Nil(t, openapiAgentConnectionDTO2Domain(nil))

0 commit comments

Comments
 (0)