fix(agentic): forward fleet capabilities to fallback polling
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
ace8cf4462
commit
9a9cf8e40b
2 changed files with 41 additions and 4 deletions
|
|
@ -282,6 +282,36 @@ func TestPlatform_HandleFleetEvents_Good_FallbackToTaskNext(t *testing.T) {
|
|||
assert.Equal(t, "dev", output.Event.Branch)
|
||||
}
|
||||
|
||||
func TestPlatform_FleetEventsTool_Good_ForwardsCapabilities(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/v1/fleet/events":
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
_, _ = w.Write([]byte(`{"error":"event stream unavailable"}`))
|
||||
case "/v1/fleet/task/next":
|
||||
require.Equal(t, "charon", r.URL.Query().Get("agent_id"))
|
||||
require.Equal(t, []string{"go", "review"}, r.URL.Query()["capabilities[]"])
|
||||
_, _ = w.Write([]byte(`{"data":{"id":13,"repo":"core/go-io","branch":"dev","task":"Fix tests","template":"coding","agent_model":"codex","status":"assigned"}}`))
|
||||
default:
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
subsystem := testPrepWithPlatformServer(t, server, "secret-token")
|
||||
_, output, err := subsystem.fleetEventsTool(context.Background(), nil, FleetEventsInput{
|
||||
AgentID: "charon",
|
||||
Capabilities: []string{"go", "review"},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "task.assigned", output.Event.Event)
|
||||
assert.Equal(t, "charon", output.Event.AgentID)
|
||||
assert.Equal(t, 13, output.Event.TaskID)
|
||||
assert.Equal(t, "core/go-io", output.Event.Repo)
|
||||
assert.Equal(t, "dev", output.Event.Branch)
|
||||
}
|
||||
|
||||
func TestPlatform_HandleFleetEvents_Bad_NoTaskAvailable(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,12 @@ type FleetTaskCompleteInput struct {
|
|||
Report map[string]any `json:"report,omitempty"`
|
||||
}
|
||||
|
||||
// input := agentic.FleetEventsInput{AgentID: "charon", Capabilities: []string{"go", "review"}}
|
||||
type FleetEventsInput struct {
|
||||
AgentID string `json:"agent_id,omitempty"`
|
||||
Capabilities []string `json:"capabilities,omitempty"`
|
||||
}
|
||||
|
||||
func (s *PrepSubsystem) registerPlatformTools(server *mcp.Server) {
|
||||
mcp.AddTool(server, &mcp.Tool{
|
||||
Name: "agentic_sync_push",
|
||||
|
|
@ -364,10 +370,11 @@ func (s *PrepSubsystem) fleetStatsTool(ctx context.Context, _ *mcp.CallToolReque
|
|||
return nil, output, nil
|
||||
}
|
||||
|
||||
func (s *PrepSubsystem) fleetEventsTool(ctx context.Context, _ *mcp.CallToolRequest, input struct {
|
||||
AgentID string `json:"agent_id,omitempty"`
|
||||
}) (*mcp.CallToolResult, FleetEventOutput, error) {
|
||||
result := s.handleFleetEvents(ctx, platformOptions(core.Option{Key: "agent_id", Value: input.AgentID}))
|
||||
func (s *PrepSubsystem) fleetEventsTool(ctx context.Context, _ *mcp.CallToolRequest, input FleetEventsInput) (*mcp.CallToolResult, FleetEventOutput, error) {
|
||||
result := s.handleFleetEvents(ctx, platformOptions(
|
||||
core.Option{Key: "agent_id", Value: input.AgentID},
|
||||
core.Option{Key: "capabilities", Value: input.Capabilities},
|
||||
))
|
||||
if !result.OK {
|
||||
return nil, FleetEventOutput{}, resultErrorValue("agentic.fleet.events", result)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue