Skip to content

fix: register --force flag on agentCmd for cobra parsing#53

Merged
rsnodgrass merged 1 commit intomainfrom
ryan/ox-status-check
Feb 23, 2026
Merged

fix: register --force flag on agentCmd for cobra parsing#53
rsnodgrass merged 1 commit intomainfrom
ryan/ox-status-check

Conversation

@rsnodgrass
Copy link
Copy Markdown
Contributor

@rsnodgrass rsnodgrass commented Feb 23, 2026

Summary

Fixed ox agent <id> session abort --force failing with "unknown flag" error. Cobra was intercepting the flag before the abort handler could read it via custom hasFlag().

Changes

  • Register --force as a persistent flag on agentCmd so cobra recognizes it
  • Update abort handler to read flag via cmd.Flag() instead of custom hasFlag()
  • Remove unused hasFlag() helper
  • Add regression test (TestAbortForceViaCobraFlag) ensuring flag works through cobra's API in non-interactive mode

Friction Telemetry

No impact — other unknown flags still trigger FailureUnknownFlag friction events for agent learning.

Co-Authored-By: SageOx ox@sageox.ai

Summary by CodeRabbit

  • New Features
    • Added --force flag to the agent session abort command, enabling non-interactive destructive operations without confirmation prompts.

Cobra was intercepting --force before the abort handler could read it, causing
"unknown flag" errors. Register --force as a persistent flag on agentCmd so cobra
recognizes it. Update abort handler to read via cmd.Flag() instead of custom
hasFlag(). Add regression test ensuring --force works through cobra's flag API.

Preserves friction telemetry: other unknown flags still trigger FailureUnknownFlag
events for agent learning.

Co-Authored-By: SageOx <ox@sageox.ai>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 23, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0a2431 and ca0ab5d.

📒 Files selected for processing (3)
  • cmd/ox/agent.go
  • cmd/ox/agent_session_abort.go
  • cmd/ox/agent_session_abort_test.go

📝 Walkthrough

Walkthrough

This PR refactors the agent session abort command to integrate Cobra's flag handling system. It introduces a hidden force flag on the ox agent command, changes the runAgentSessionAbort function signature to accept a cobra.Command object instead of raw arguments, replaces manual flag detection with Cobra's flag retrieval, and updates corresponding tests.

Changes

Cohort / File(s) Summary
Agent Session Abort Command Refactoring
cmd/ox/agent.go, cmd/ox/agent_session_abort.go, cmd/ox/agent_session_abort_test.go
Migrates from argument-based to Cobra-based flag handling for the session abort command. Changes runAgentSessionAbort signature to accept cobra.Command instead of args, replaces manual flag detection with cmd.Flag("force"), adds a hidden persistent force flag on the agent command, and introduces new test helper and validation to ensure flags are properly read through Cobra integration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A hop and a flag, now Cobra takes the lead,
No more manual args, just what we all need!
Force flows through the system, clean and so right,
Tests dance with the helpers, all working tonight! ✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ryan/ox-status-check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rsnodgrass rsnodgrass marked this pull request as ready for review February 23, 2026 23:52
@rsnodgrass rsnodgrass merged commit 3d2f4a0 into main Feb 23, 2026
1 check was pending
@rsnodgrass rsnodgrass deleted the ryan/ox-status-check branch February 23, 2026 23:52
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.

1 participant