Skip to content

Delegate cron prompt command building to AgentCLI implementations#339

Merged
tbrandenburg merged 1 commit intomainfrom
codex/refactor-agent-cli-command-handling
Mar 30, 2026
Merged

Delegate cron prompt command building to AgentCLI implementations#339
tbrandenburg merged 1 commit intomainfrom
codex/refactor-agent-cli-command-handling

Conversation

@tbrandenburg
Copy link
Copy Markdown
Owner

Motivation

  • Prevent duplication and drift by moving CLI-specific prompt command construction out of cron_service and into each AgentCLI implementation so the CLI class is authoritative for its invocation semantics.
  • Make stdin-vs-argument prompt detection explicit per-CLI rather than relying on executable name heuristics scattered across code.

Description

  • Added a new abstract method build_prompt_command(prompt: str) -> list[str] and hook prompt_via_stdin() to AgentCLI in packages/pybackend/agent_cli.py so CLIs can provide their prompt command and whether they accept prompt via stdin.
  • Implemented build_prompt_command and prompt_via_stdin where appropriate in packages/pybackend/copilot_agent_cli.py, codex_agent_cli.py, kiro_agent_cli.py, opencode_database_agent_cli.py, ob1_agent_cli.py and the base OpenCodeAgentCLI.
  • Simplified packages/pybackend/cron_service.py so _build_agent_cli_command delegates to get_agent_cli().build_prompt_command(prompt) and _uses_stdin_prompt() now uses get_agent_cli().prompt_via_stdin().
  • Updated unit tests in packages/pybackend/tests/unit/test_cron_service.py to mock the new AgentCLI contract (build_prompt_command and prompt_via_stdin) instead of relying on cli_name/main_executable_name behavior.

Testing

  • Ran CLI unit tests with python -m pytest packages/pybackend/tests/unit/test_copilot_agent_cli.py packages/pybackend/tests/unit/test_kiro_agent_cli.py packages/pybackend/tests/unit/test_codex_agent_cli.py packages/pybackend/tests/unit/test_ob1_agent_cli.py packages/pybackend/tests/unit/test_opencode_database_agent_cli.py and all contained tests passed.
  • Ran cron-related unit tests with python -m pytest packages/pybackend/tests/unit/test_cron_service.py but collection failed in this environment due to a missing apscheduler dependency, preventing full execution of that file here.
  • The changes are limited to command-building and tests were updated accordingly, with the non-CLI-test failures attributable to the test environment rather than the refactor itself.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
made Ready Ready Preview, Comment Mar 30, 2026 10:25am

@tbrandenburg tbrandenburg merged commit bf0b805 into main Mar 30, 2026
8 checks passed
@tbrandenburg tbrandenburg deleted the codex/refactor-agent-cli-command-handling branch March 30, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant