Skip to content

Agent: enforce maxItems and dryRun in orchestrator #115

@federiconeri

Description

@federiconeri

Summary

AgentConfig.maxItems and AgentConfig.dryRun are accepted by the CLI (wiggum agent --max-items 5 --dry-run) and passed through to createAgentOrchestrator, but the orchestrator never reads or enforces them.

Problem / Context

Currently the agent relies entirely on the LLM to self-limit based on the system prompt mentioning "maximum number of items". This is unreliable — the model may ignore it or lose track of the count.

For dryRun, there are no guardrails preventing the agent from calling runLoop or commentOnIssue when dry-run mode is active.

Discovered during code review of #114.

Proposed Solution

maxItems

Add a counter in onStepFinish that tracks how many issues have been completed (by detecting reflectOnWork tool calls). When the count reaches maxItems, signal the agent to stop — either by:

  • Injecting a "you have reached the item limit, stop now" message via prepareStep
  • Or using a custom stopWhen condition

dryRun

Wrap execution and reporting tools with guards that return mock results when dryRun is true:

  • generateSpec → return { success: true, specPath: '(dry-run)' }
  • runLoop → return { status: 'dry-run' }
  • commentOnIssue → return { success: true } without calling gh
  • createTechDebtIssue → return { success: true } without calling gh

Files to Modify

File Changes
src/agent/orchestrator.ts Read maxItems/dryRun from config, implement enforcement
src/agent/orchestrator.test.ts Add tests for item counting and dry-run behavior
src/agent/tools/execution.ts Accept dryRun option or wrap at orchestrator level
src/agent/tools/reporting.ts Accept dryRun option or wrap at orchestrator level

Acceptance Criteria

  • --max-items 3 stops the agent after 3 issues are reflected on
  • --dry-run prevents any gh calls or wiggum run/wiggum new spawns
  • Tests verify both behaviors

Metadata

Metadata

Assignees

Labels

ai/llmAI workflows, agents, promptscliCommand line interface, commands, entry pointsenhancementEnhancement to existing feature

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions