diff options
Diffstat (limited to 'internal/executor/agentmcp_test.go')
| -rw-r--r-- | internal/executor/agentmcp_test.go | 60 |
1 files changed, 53 insertions, 7 deletions
diff --git a/internal/executor/agentmcp_test.go b/internal/executor/agentmcp_test.go index c73d6db..18299e8 100644 --- a/internal/executor/agentmcp_test.go +++ b/internal/executor/agentmcp_test.go @@ -8,17 +8,20 @@ import ( "testing" "github.com/modelcontextprotocol/go-sdk/mcp" + "github.com/thepeterstone/claudomator/internal/role" ) // recordingChannel is a fake AgentChannel that records tool invocations. type recordingChannel struct { - asked string - summary string - spawned []SubtaskSpec - progress []string - spawnID string - proposedEpics []EpicProposal - epicID string + asked string + summary string + spawned []SubtaskSpec + progress []string + spawnID string + proposedEpics []EpicProposal + epicID string + proposedRoleConfigs []role.RoleConfig + roleConfigVersion int } func (c *recordingChannel) AskUser(_ context.Context, q string) (string, error) { @@ -41,6 +44,10 @@ func (c *recordingChannel) ProposeEpic(_ context.Context, spec EpicProposal) (st c.proposedEpics = append(c.proposedEpics, spec) return c.epicID, nil } +func (c *recordingChannel) ProposeRoleConfig(_ context.Context, cfg role.RoleConfig) (int, error) { + c.proposedRoleConfigs = append(c.proposedRoleConfigs, cfg) + return c.roleConfigVersion, nil +} func resultText(t *testing.T, res *mcp.CallToolResult) string { t.Helper() @@ -209,6 +216,45 @@ func TestAgentServer_ProposeEpic(t *testing.T) { } } +// TestAgentServer_ProposeRoleConfig proves the propose_role_config MCP tool +// reaches AgentChannel.ProposeRoleConfig with the full role.RoleConfig shape +// decoded correctly, including a nested escalation_ladder tier -- mirroring +// TestAgentServer_ProposeEpic's coverage above for this phase's new tool. +func TestAgentServer_ProposeRoleConfig(t *testing.T) { + ch := &recordingChannel{roleConfigVersion: 3} + cs := connectInMemory(t, newAgentServer(ch)) + res, err := cs.CallTool(context.Background(), &mcp.CallToolParams{ + Name: "propose_role_config", + Arguments: map[string]any{ + "role": "builder", + "system_prompt": "Double-check edge cases before finishing.", + "escalation_ladder": []map[string]any{ + { + "candidates": []map[string]any{{"provider": "anthropic", "model": "claude-sonnet-4-6"}}, + "max_retries": 1, + }, + }, + }, + }) + if err != nil { + t.Fatalf("CallTool: %v", err) + } + if len(ch.proposedRoleConfigs) != 1 { + t.Fatalf("expected 1 proposed role config, got %d", len(ch.proposedRoleConfigs)) + } + cfg := ch.proposedRoleConfigs[0] + if cfg.Role != "builder" || cfg.SystemPrompt != "Double-check edge cases before finishing." { + t.Errorf("role config not propagated: %+v", cfg) + } + if len(cfg.EscalationLadder) != 1 || len(cfg.EscalationLadder[0].Candidates) != 1 || + cfg.EscalationLadder[0].Candidates[0].Provider != "anthropic" || cfg.EscalationLadder[0].Candidates[0].Model != "claude-sonnet-4-6" { + t.Errorf("escalation_ladder not propagated: %+v", cfg.EscalationLadder) + } + if txt := resultText(t, res); !strings.Contains(txt, "builder") || !strings.Contains(txt, "3") { + t.Errorf("expected role name and version in result, got %q", txt) + } +} + type bearerRT struct { token string base http.RoundTripper |
