Skip to content

Conversation

@frankbria
Copy link
Owner

@frankbria frankbria commented Feb 9, 2026

Summary

Implements #368: adds 3 CLI integration tests exercising the full CLI → runtime → ReactAgent path with MockProvider.

Test plan

  • All 3 new tests pass (TestReactAgentIntegration)
  • Full test suite (79 tests) passes with no regressions
  • Ruff linting clean
  • Tests use CliRunner with MockProvider (no real LLM calls)
  • Tests inherit @pytest.mark.v2 via file-level pytestmark

Implementation notes

Closes #368

Summary by CodeRabbit

  • Tests
    • Added end-to-end CLI integration tests for ReactAgent interactions.
    • Validates verbose-mode output, dry-run indicators, and streaming output/log presentation to ensure correct CLI behavior.

Exercise the full CLI → runtime → ReactAgent path with MockProvider to
catch wiring issues that unit tests with mocked dependencies miss.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

Walkthrough

Adds CLI integration tests for the ReactAgent engine: introduces a module-level mock completion, imports runtime helpers, and a TestReactAgentIntegration class with tests for verbose mode, dry-run, and streaming output logging via the CLI→runtime→ReactAgent path.

Changes

Cohort / File(s) Summary
ReactAgent CLI Integration Tests
tests/cli/test_v2_cli_integration.py
Added MOCK_REACT_COMPLETION constant; imported runtime and run_output_exists; added TestReactAgentIntegration with three tests: test_react_verbose_mode, test_react_dry_run, test_react_streaming_output_log to validate verbose markers, dry-run behavior, and streaming/output log via CLI.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through fixtures, tiny and spry,

Mocked a react reply to watch logs fly,
Verbose whispers, dry-run hush, stream's bright gleam,
CLI paths checked — I twitched, I dreamed, I beam,
A carrot-coded cheer for the test-time team!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding CLI integration tests for ReactAgent runtime parameters, matching the PR's primary objective of implementing issue #368.
Linked Issues check ✅ Passed The PR successfully implements all three acceptance criteria from issue #368: verbose mode test, dry-run mode test, and streaming output test, all marked with @pytest.mark.v2 and using MockProvider.
Out of Scope Changes check ✅ Passed All changes are scoped to adding CLI integration tests for ReactAgent; no unrelated modifications to production code or other test suites are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/issue-368-react-integration-tests

No actionable comments were generated in the recent review. 🎉


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

@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Feb 9, 2026

Add CLI integration tests that verify ReactAgent runtime parameters in [tests/cli/test_v2_cli_integration.py] (https://github.com/frankbria/codeframe/pull/369/files#diff-a951fb27e719d66f510235ce51f37279ec98f6f02178397fa55cda32fb0a16c2)

Introduce three ReactAgent CLI integration tests covering verbose mode, dry-run, and streaming output, with imports extended to use codeframe.core.runtime.list_runs and codeframe.core.streaming.run_output_exists.

📍Where to Start

Start with the TestReactAgentIntegration class in test_v2_cli_integration.py, then review its three test methods.


Macroscope summarized 528e91a.

@claude
Copy link

claude bot commented Feb 9, 2026

Code Review

Summary

This PR adds 3 well-structured CLI integration tests for ReactAgent runtime parameters, closing the testing gap identified in PR #367. The tests follow established patterns and provide valuable end-to-end coverage.

✅ Strengths

  1. Excellent Test Structure

    • Tests follow existing conventions in test_v2_cli_integration.py
    • Clear class organization (TestReactAgentIntegration)
    • Comprehensive docstrings explaining purpose and scope
    • Proper use of pytestmark inheritance for v2 marker
  2. Good Mock Strategy

    • MOCK_REACT_COMPLETION is well-placed near other mock constants (line 775)
    • Text-only response appropriately triggers ReactAgent completion (no tool calls)
    • Proper use of mock_llm fixture with queued responses
  3. Solid Test Coverage

  4. Proper Error Messaging

    • All assertions include descriptive failure messages with result.output context
    • Multi-line assertion messages use proper Python formatting

💡 Suggestions

1. Minor: Import Organization (Low Priority)

The streaming test imports modules inline (lines 1039, 1044):

from codeframe.core import runtime
from codeframe.core.streaming import run_output_exists

Recommendation: Move to top-level imports for consistency with file conventions (see line 21: from codeframe.core import prd, tasks).

Rationale: While inline imports work fine and may have been used to avoid pytest collection issues, the file already imports from codeframe.core at the top.

2. Enhancement Opportunity: Verify Follow Output Content (Optional)

The streaming test verifies that cf work follow exits successfully but doesn't check if the output contains expected content from the ReactAgent execution.

Suggestion:

assert follow_result.exit_code == 0, f"follow failed: {follow_result.output}"
# Optional: Verify follow actually shows the agent output
assert "Task analysis complete" in follow_result.output or len(follow_result.output) > 0

Rationale: This would ensure follow is actually reading and displaying the output.log content, not just returning success on an empty read.

3. Test Independence Consideration

All three tests use the same workspace_with_ready_tasks fixture and consume its first READY task. Since the workspace is modified during execution (tasks transition to DONE), tests may have order dependencies.

Recommendation: Verify tests pass when run in isolation and in different orders:

pytest tests/cli/test_v2_cli_integration.py::TestReactAgentIntegration::test_react_dry_run -v
pytest tests/cli/test_v2_cli_integration.py::TestReactAgentIntegration -v --random-order

Note: If workspace_with_ready_tasks creates a fresh fixture per test, this is a non-issue.

🔒 No Issues Found

  • Security: ✅ No security concerns (uses test fixtures and mock providers)
  • Performance: ✅ Appropriate for integration tests (no real LLM calls)
  • Best Practices: ✅ Follows repository patterns from CLAUDE.md
  • Test Markers: ✅ Properly inherits @pytest.mark.v2 via file-level pytestmark

📋 Checklist

Verdict

LGTM ✅ with minor optional enhancements suggested above. The tests provide solid end-to-end coverage of ReactAgent runtime parameters through the CLI path. The implementation is clean, well-documented, and follows established patterns.

The adaptation from the original plan (dry-run expecting success rather than failure) shows good judgment based on PR #367's implementation.


Reviewed according to CLAUDE.md Phase 2.5-C guidelines

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/cli/test_v2_cli_integration.py`:
- Around line 1040-1046: list_runs returns runs ordered newest-first, so change
the test to pick the first element instead of the last: replace uses of runs[-1]
with runs[0] (and consider renaming last_run to recent_run) where
runtime.list_runs(ws, task_id=task_list[0].id) is consumed before calling
run_output_exists(ws, <run_id>), ensuring you assert the output exists for the
most recent run.

Captures mock_llm return value and asserts call_count >= 1 in all three
tests, matching the existing pattern in TestAIAgentExecution.
@claude
Copy link

claude bot commented Feb 9, 2026

Follow-up Review

I've reviewed the PR again and noticed CodeRabbit identified a bug in the streaming test that I missed in my initial review.

Bug Found by CodeRabbit

Issue: Line 1045 uses runs[-1] to get the "last" run, but list_runs() returns runs newest-first (confirmed in runtime.py:287 and SQL query ORDER BY started_at DESC at line 307).

Impact: The test is checking the oldest run instead of the most recent one, which could cause false positives/negatives.

Fix needed in test_react_streaming_output_log:

Change line 1045 from:
last_run = runs[-1] # Gets OLDEST run

To:
recent_run = runs[0] # Gets NEWEST run (just executed)

Then update line 1048 to use recent_run.id instead of last_run.id.

Updated Verdict

Requires fix before merge. Once the runs[-1] to runs[0] change is made, this will be a solid addition. All other aspects of the implementation remain excellent.

Credit to CodeRabbit for catching this indexing issue.


Previous feedback (import organization, output content verification, test independence) remains as optional suggestions - the indexing bug is the only blocking issue.

- Fix runs[-1] → runs[0]: list_runs returns newest first (CodeRabbit)
- Move inline imports to top-level for consistency (Claude)
- Assert follow output is non-empty to verify content display (Claude)
- Rename last_run → latest_run for clarity
@claude
Copy link

claude bot commented Feb 9, 2026

Final Review - All Feedback Addressed ✅

I've reviewed the updated PR after all three commits, and I'm pleased to confirm that all previous review feedback has been properly addressed.

Changes Applied

Commit 1 (3085515): Initial implementation

  • Added 3 CLI integration tests for ReactAgent runtime parameters
  • Comprehensive test coverage: verbose mode, dry-run, streaming output

Commit 2 (9b27929): CodeRabbit feedback

  • Added provider.call_count >= 1 assertions to all three tests
  • Ensures mock provider is actually being called

Commit 3 (528e91a): Combined feedback from CodeRabbit and Claude

  • Fixed indexing bug: Changed runs[-1]runs[0] (list_runs returns newest first)
  • Renamed variable: last_runlatest_run for clarity
  • Moved imports: Inline imports now at top-level (lines 21, 23)
  • Enhanced assertion: Added non-empty output check in follow test (line 1062)

Code Quality Assessment

Strengths:

  1. Excellent test structure - Clear class organization, comprehensive docstrings
  2. Proper mock strategy - MockProvider with queued responses, no real API calls
  3. Full end-to-end coverage - Tests verify complete CLI → runtime → ReactAgent path
  4. Follows conventions - Inherits @pytest.mark.v2 marker, matches existing patterns
  5. Good error messages - All assertions include descriptive failure context

Security: ✅ No concerns - uses test fixtures and mock providers
Performance: ✅ Appropriate - no real LLM calls, fast execution
Best Practices: ✅ Follows CLAUDE.md Phase 2 guidelines
Test Coverage: ✅ All 3 acceptance criteria from issue #368 met

Verification

The fixes correctly address:

  • Runtime behavior: list_runs() returns newest first per line 287 in runtime.py
  • Import organization: Follows file convention of top-level imports from codeframe.core
  • Output verification: Streaming test now confirms follow displays actual content

Verdict

APPROVED ✅ - Ready to merge

This PR delivers solid end-to-end testing for ReactAgent runtime parameters. The implementation is clean, well-documented, and properly responds to review feedback. Excellent work on the iterative improvements!

Closes #368


Review iteration 2/2 - all feedback addressed

@frankbria frankbria merged commit 654117d into main Feb 9, 2026
11 checks passed
@frankbria frankbria deleted the feature/issue-368-react-integration-tests branch February 9, 2026 22:29
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.

[Phase 2.5-C] Integration tests for ReactAgent runtime parameters

1 participant