Skip to content

feat(agents): fix CLI provider invocations and add streaming output support (F078)#304

Merged
pocky merged 1 commit intomainfrom
feature/F078-fix-cli-provider-invocations-breaking-ch
Apr 8, 2026
Merged

feat(agents): fix CLI provider invocations and add streaming output support (F078)#304
pocky merged 1 commit intomainfrom
feature/F078-fix-cli-provider-invocations-breaking-ch

Conversation

@pocky
Copy link
Copy Markdown
Contributor

@pocky pocky commented Apr 8, 2026

Summary

  • Fix CLI invocation flags for all 4 providers to match current binary APIs: Claude/Gemini --output-format jsonstream-json, Codex --prompt/--quietexec --json <prompt>, OpenCode gains --format json and --model support
  • Add stdout, stderr io.Writer parameters to Execute and ExecuteConversation in the ports interface and all provider implementations, enabling streaming output propagation
  • Remove dead validation helpers (validatePrompt, validateContext, validateState, validateCodexOptions) that became no-ops after previous provider refactoring

Changes

Ports / Interface

  • internal/domain/ports/agent_provider.go: Add stdout, stderr io.Writer params to Execute and ExecuteConversation signatures
  • internal/domain/ports/agent_provider_test.go: Update interface tests for new signature
  • internal/domain/ports/cli_executor.go: Propagate writer params through CLI executor abstraction
  • internal/domain/ports/cli_executor_test.go: Update tests

Provider Implementations

  • internal/infrastructure/agents/claude_provider.go: Map output_format: json--output-format stream-json; accept stream-json pass-through; wire stdout/stderr writers
  • internal/infrastructure/agents/codex_provider.go: Migrate from --prompt/--quiet to exec --json <prompt>; resume from codex resume <id> --prompt to codex resume <id> --json; remove quiet option
  • internal/infrastructure/agents/gemini_provider.go: Map output_format: json--output-format stream-json; wire writers
  • internal/infrastructure/agents/opencode_provider.go: Add --format json always-on flag and --model option support; wire writers
  • internal/infrastructure/agents/openai_compatible_provider.go: Update signature to accept stdout/stderr writers
  • internal/infrastructure/agents/cli_executor.go: Wire writer params through CLI execution
  • internal/infrastructure/agents/helpers.go: Remove dead validation helpers (validatePrompt, validateContext, validateState)
  • internal/infrastructure/agents/options.go: Add output_format / quiet option declarations

Application Layer

  • internal/application/conversation_manager.go: Thread stdoutW, stderrW io.Writer through executeTurn and ExecuteConversation
  • internal/application/execution_service.go: Pass writers through agent step and conversation execution

Mocks & Test Infrastructure

  • internal/testutil/mocks/mocks.go: Update MockAgentProvider to match new Execute/ExecuteConversation signatures
  • internal/testutil/mocks/mocks_agent_test.go: Update mock tests
  • internal/testutil/mocks/mocks_cli_executor_test.go: Update CLI executor mock tests

Tests

  • internal/infrastructure/agents/claude_provider_stream_json_test.go (new): Tests for stream-json output format flag mapping
  • internal/infrastructure/agents/codex_provider_exec_test.go (new): Tests for codex exec --json invocation
  • internal/infrastructure/agents/codex_provider_resume_test.go (new): Tests for codex resume --json conversation resume
  • internal/infrastructure/agents/claude_provider_unit_test.go: Extend unit tests for new flag behavior
  • internal/infrastructure/agents/codex_provider_unit_test.go: Extend unit tests; remove quiet option tests
  • internal/infrastructure/agents/codex_provider_model_unit_test.go: Trim tests no longer applicable after exec migration
  • internal/infrastructure/agents/codex_provider_session_test.go: Update session tests for resume flag change
  • internal/infrastructure/agents/gemini_provider_unit_test.go: Extend tests for stream-json mapping
  • internal/infrastructure/agents/gemini_provider_session_test.go: Update session tests
  • internal/infrastructure/agents/opencode_provider_unit_test.go: Extend tests for --format json and --model
  • internal/infrastructure/agents/opencode_provider_session_test.go: Update session tests
  • internal/infrastructure/agents/openai_compatible_provider_test.go: Update for new signature
  • internal/infrastructure/agents/openai_compatible_provider_unit_test.go: Update unit tests
  • internal/infrastructure/agents/helpers_test.go: Remove tests for deleted helpers
  • internal/infrastructure/agents/cli_executor_test.go: Update for writer params
  • internal/infrastructure/agents/mock_provider.go: Update mock to new interface
  • internal/infrastructure/agents/mock_provider_test.go: Update mock tests
  • internal/infrastructure/agents/provider_options_test.go: Update option validation tests
  • internal/infrastructure/agents/registry_test.go: Minor updates
  • internal/application/agent_step_test.go: Update all SetExecuteFunc callbacks to new signature
  • internal/application/conversation_manager.go: Already covered above
  • internal/application/conversation_manager_helpers_test.go: Update internal mock to new interface
  • internal/application/conversation_manager_test.go: Pass nil, nil writers in all ExecuteConversation calls
  • internal/application/execution_service_conversation_step_test.go (renamed from t009): Rename for clarity
  • internal/application/execution_service_conversation_test.go: Minor updates
  • internal/application/execution_service_dangerous_skip_audit_test.go: Minor updates
  • internal/application/execution_service_hooks_test.go: Minor updates
  • internal/application/execution_service_json_field_mapping_test.go: Minor updates
  • internal/application/execution_service_output_format_test.go: Update for new stream-json mapping
  • tests/integration/execution/provider_interpolation_test.go: Minor updates

Documentation

  • CHANGELOG.md: Document F078 breaking changes (flag migrations, removed quiet option) and additions (OpenCode --model, --format json)
  • CLAUDE.md: Add architecture rule to synchronize provider CLI flag changes with options.go; remove stale review section

Test plan

  • Run unit tests: make test-unit — all provider flag-construction tests pass
  • Verify Codex invocation builds exec --json <prompt> and resume builds codex resume <id> --json <prompt>: check codex_provider_exec_test.go and codex_provider_resume_test.go
  • Verify Claude/Gemini output_format: json in a workflow YAML produces --output-format stream-json in the CLI command: check claude_provider_stream_json_test.go
  • Run full test suite with race detector: make test-race

Closes #301


Generated with awf commit workflow

…Conversation` in the ports interface and all provider implementations

2. Fixing CLI invocation flags (Claude/Gemini `--output-format stream-json`, Codex `exec --json`, OpenCode `--format json`/`--model`)
3. Removing dead validation helpers
4. Adding new tests for stream-json, codex exec, and codex resume

fix(agents): fix CLI provider invocations and add io.Writer streaming

- `CHANGELOG.md`: Document F078 breaking changes and additions
- `CLAUDE.md`: Add rule for synchronizing options.go with provider changes
- `internal/domain/ports/agent_provider.go`: Add stdout/stderr io.Writer params to Execute and ExecuteConversation
- `internal/domain/ports/agent_provider_test.go`: Update port interface tests for new signature
- `internal/domain/ports/cli_executor.go`: Propagate io.Writer to CLI executor
- `internal/domain/ports/cli_executor_test.go`: Update executor tests for new signature
- `internal/infrastructure/agents/claude_provider.go`: Map output_format json to --output-format stream-json
- `internal/infrastructure/agents/claude_provider_stream_json_test.go`: Add stream-json output format tests
- `internal/infrastructure/agents/claude_provider_session_test.go`: Update session tests for new signature
- `internal/infrastructure/agents/claude_provider_unit_test.go`: Update unit tests for new signature
- `internal/infrastructure/agents/cli_executor.go`: Wire stdout/stderr writers to process output
- `internal/infrastructure/agents/cli_executor_test.go`: Update executor tests for new signature
- `internal/infrastructure/agents/codex_provider.go`: Migrate from --prompt/--quiet to exec --json subcommand
- `internal/infrastructure/agents/codex_provider_exec_test.go`: Add exec subcommand invocation tests
- `internal/infrastructure/agents/codex_provider_resume_test.go`: Add resume --json flag tests
- `internal/infrastructure/agents/codex_provider_session_test.go`: Update session tests
- `internal/infrastructure/agents/codex_provider_unit_test.go`: Update unit tests for new invocation
- `internal/infrastructure/agents/codex_provider_model_unit_test.go`: Update model tests
- `internal/infrastructure/agents/gemini_provider.go`: Map output_format json to --output-format stream-json
- `internal/infrastructure/agents/gemini_provider_session_test.go`: Update session tests
- `internal/infrastructure/agents/gemini_provider_unit_test.go`: Expand unit tests for flag mapping
- `internal/infrastructure/agents/helpers.go`: Remove dead validatePrompt/validateContext/validateState helpers
- `internal/infrastructure/agents/helpers_test.go`: Remove tests for deleted helpers
- `internal/infrastructure/agents/mock_provider.go`: Update mock to new Execute/ExecuteConversation signature
- `internal/infrastructure/agents/mock_provider_test.go`: Update mock tests
- `internal/infrastructure/agents/openai_compatible_provider.go`: Update to new interface signature
- `internal/infrastructure/agents/openai_compatible_provider_test.go`: Update integration tests
- `internal/infrastructure/agents/openai_compatible_provider_unit_test.go`: Update unit tests
- `internal/infrastructure/agents/opencode_provider.go`: Add --format json and --model flag support
- `internal/infrastructure/agents/opencode_provider_session_test.go`: Update session tests
- `internal/infrastructure/agents/opencode_provider_unit_test.go`: Expand unit tests for new flags
- `internal/infrastructure/agents/options.go`: Add output_format option declaration
- `internal/infrastructure/agents/provider_options_test.go`: Update options tests
- `internal/infrastructure/agents/registry_test.go`: Update registry tests
- `internal/application/execution_service.go`: Pass stdout/stderr writers to provider calls
- `internal/application/execution_service_conversation_step_test.go`: Rename from t009, update signature
- `internal/application/execution_service_conversation_test.go`: Update for new signature
- `internal/application/execution_service_dangerous_skip_audit_test.go`: Update for new signature
- `internal/application/execution_service_hooks_test.go`: Update for new signature
- `internal/application/execution_service_json_field_mapping_test.go`: Update for new signature
- `internal/application/execution_service_output_format_test.go`: Update for new signature
- `internal/application/agent_step_test.go`: Update all mock execute funcs for new signature
- `internal/application/conversation_manager.go`: Add stdout/stderr params to executeTurn and ExecuteConversation
- `internal/application/conversation_manager_helpers_test.go`: Update mock for new signature
- `internal/application/conversation_manager_test.go`: Update all ExecuteConversation calls
- `internal/testutil/mocks/mocks.go`: Update mock Execute/ExecuteConversation signatures
- `internal/testutil/mocks/mocks_agent_test.go`: Update mock agent tests
- `internal/testutil/mocks/mocks_cli_executor_test.go`: Update CLI executor mock tests
- `tests/integration/execution/provider_interpolation_test.go`: Update for new signature

Closes #301
@pocky pocky changed the title 1. Adding stdout, stderr io.Writer params to Execute and ExecuteConversation in the ports interface and all provider implementations 2. Fixing CLI invocation flags (Claude/Gemini --output-format stream-json, Codex exec --json, OpenCode --format json/--model) 3. Removing dead validation helpers 4. Adding new tests for stream-json, codex exec, and codex resume feat(agents): fix CLI provider invocations and add streaming output support (F078) Apr 8, 2026
@pocky pocky marked this pull request as ready for review April 8, 2026 09:46
@pocky pocky merged commit 86cb65e into main Apr 8, 2026
5 checks passed
@pocky pocky deleted the feature/F078-fix-cli-provider-invocations-breaking-ch branch April 8, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F078: Fix CLI Provider Invocations (Breaking Change)

1 participant