Skip to content

fix(agents): show final result before human feedback when not verbose#6189

Open
HumphreySun98 wants to merge 3 commits into
crewAIInc:mainfrom
HumphreySun98:fix/human-input-show-result-non-verbose
Open

fix(agents): show final result before human feedback when not verbose#6189
HumphreySun98 wants to merge 3 commits into
crewAIInc:mainfrom
HumphreySun98:fix/human-input-show-result-non-verbose

Conversation

@HumphreySun98

@HumphreySun98 HumphreySun98 commented Jun 16, 2026

Copy link
Copy Markdown

Problem

When a Task has human_input=True but neither the agent nor the crew is verbose, CrewAI shows the 💬 Human Feedback Required panel — "Provide feedback on the Final Result above" — but the result is never printed. The two behaviours are gated independently:

  • the result render (AgentLogsExecutionEvent, and streaming) is gated on verbose;
  • the feedback prompt fires whenever human_input=True.

So a non-verbose human-in-the-loop run asks the operator to approve output they cannot see.

Fix

Render the result through the existing console formatter (handle_agent_logs_execution) right before each feedback prompt when verbose is off — reusing the existing rendering path rather than an ad-hoc print. Covers both the sync and async providers and every feedback round. It is a no-op when verbose, to avoid a duplicate panel.

Tests

Added lib/crewai/tests/core/providers/test_human_input.py asserting the result is rendered before the prompt when not verbose, and not re-rendered when verbose. Verified failing-without/passing-with the fix; ruff and mypy clean.

Fixes #6072


This PR was authored with Claude Code. Per CONTRIBUTING.md, AI-generated contributions require the llm-generated label — I don't have triage permission to set it, so could a maintainer please add it? 🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Updated the human feedback prompt flow to ensure the “Final Result above” is rendered before requesting feedback when not in verbose mode.
    • Prevents duplicate result output when either the agent or crew is in verbose mode.
  • Tests

    • Added/expanded regression tests for both synchronous and asynchronous feedback flows to verify correct render ordering and ensure no duplicate result panels are shown in verbose scenarios.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ea7a61f2-63e8-4e06-8fce-16a9f94fd9d8

📥 Commits

Reviewing files that changed from the base of the PR and between 9135caf and a292a23.

📒 Files selected for processing (1)
  • lib/crewai/tests/core/providers/test_human_input.py

📝 Walkthrough

Walkthrough

Adds conditional result rendering to human feedback handling so the agent output is shown before feedback is requested when verbose mode is off. The sync and async feedback paths, including rerun loops, now invoke the same guard, and tests cover ordering plus duplicate-render prevention.

Changes

Conditional result rendering before human feedback

Layer / File(s) Summary
Result render guard and prompt wiring
lib/crewai/src/crewai/core/providers/human_input.py
Adds _ensure_result_displayed(answer, context) to render agent logs only when agent.verbose and crew.verbose are both false, and calls it before the feedback prompt and after reruns in the sync and async flows.
Sync and async regression coverage
lib/crewai/tests/core/providers/test_human_input.py
Adds fake agent/crew/context scaffolding and sync/async tests that verify logs render before the prompt in non-verbose cases and are not re-rendered when the crew or agent is already verbose.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main user-facing fix for non-verbose human feedback flows.
Linked Issues check ✅ Passed The change satisfies #6072 by rendering the final result before human feedback in non-verbose sync and async flows, while avoiding duplicate renders in verbose mode.
Out of Scope Changes check ✅ Passed The added async handling and regression tests are directly tied to the bug fix and do not introduce unrelated scope.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/crewai/tests/core/providers/test_human_input.py (1)

41-82: ⚡ Quick win

Add async-path regression coverage for the new display hook.

These tests validate the sync path, but this PR also changes async entry/loop paths. Please add async parity tests so ordering and dedup behavior are protected there too.

Suggested test additions
+from unittest.mock import AsyncMock
+import asyncio
...
+    def test_result_shown_before_prompt_async_when_not_verbose(self) -> None:
+        provider = SyncHumanInputProvider()
+        context = _FakeContext(_FakeAgent(verbose=False), _FakeCrew(verbose=False))
+        answer = _answer()
+
+        formatter = MagicMock()
+        with (
+            patch.object(event_listener, "formatter", formatter),
+            patch(
+                "crewai.core.providers.human_input._async_readline",
+                new=AsyncMock(return_value=""),
+            ),
+        ):
+            result = asyncio.run(provider.handle_feedback_async(answer, context))  # type: ignore[arg-type]
+
+        formatter.handle_agent_logs_execution.assert_called_once_with(
+            "Researcher", answer, verbose=True
+        )
+        method_calls = [c[0] for c in formatter.mock_calls]
+        assert method_calls.index("handle_agent_logs_execution") < method_calls.index("console.print")
+        assert result is answer
+
+    def test_result_not_reshown_async_when_verbose(self) -> None:
+        provider = SyncHumanInputProvider()
+        context = _FakeContext(_FakeAgent(verbose=False), _FakeCrew(verbose=True))
+
+        formatter = MagicMock()
+        with (
+            patch.object(event_listener, "formatter", formatter),
+            patch(
+                "crewai.core.providers.human_input._async_readline",
+                new=AsyncMock(return_value=""),
+            ),
+        ):
+            asyncio.run(provider.handle_feedback_async(_answer(), context))  # type: ignore[arg-type]
+
+        formatter.handle_agent_logs_execution.assert_not_called()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/crewai/tests/core/providers/test_human_input.py` around lines 41 - 82,
Add async parity tests to cover the async code paths in the human input
provider, similar to the existing sync tests in TestResultDisplayBeforeFeedback.
Create async test methods (using async def and pytest.mark.asyncio or similar)
that mirror test_result_shown_before_prompt_when_not_verbose and
test_result_not_reshown_when_verbose by testing the async entry/loop paths of
SyncHumanInputProvider or its async equivalent, ensuring the same ordering
behavior (result displayed before feedback prompt) and deduplication behavior
(no re-render when verbose) are validated for both synchronous and asynchronous
execution paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lib/crewai/tests/core/providers/test_human_input.py`:
- Around line 41-82: Add async parity tests to cover the async code paths in the
human input provider, similar to the existing sync tests in
TestResultDisplayBeforeFeedback. Create async test methods (using async def and
pytest.mark.asyncio or similar) that mirror
test_result_shown_before_prompt_when_not_verbose and
test_result_not_reshown_when_verbose by testing the async entry/loop paths of
SyncHumanInputProvider or its async equivalent, ensuring the same ordering
behavior (result displayed before feedback prompt) and deduplication behavior
(no re-render when verbose) are validated for both synchronous and asynchronous
execution paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ff177527-8ce0-4a7d-85c9-b6cb730060ca

📥 Commits

Reviewing files that changed from the base of the PR and between e9d568d and ffa5f20.

📒 Files selected for processing (4)
  • lib/crewai/src/crewai/core/providers/human_input.py
  • lib/crewai/tests/core/__init__.py
  • lib/crewai/tests/core/providers/__init__.py
  • lib/crewai/tests/core/providers/test_human_input.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/crewai/tests/core/providers/test_human_input.py (1)

114-128: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the agent.verbose=True no-op branch too.

This regression only exercises crew.verbose=True, but _ensure_result_displayed() skips rendering when either the agent or the crew is verbose. Adding the agent-verbose case here would lock the full duplicate-rendering contract down.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/crewai/tests/core/providers/test_human_input.py` around lines 114 - 128,
The `test_result_not_reshown_when_verbose` regression only covers the
`_ensure_result_displayed()` path where `crew.verbose=True`, but the same no-op
behavior should also be verified when `agent.verbose=True`. Add a focused async
test in `test_human_input.py` using `SyncHumanInputProvider`, `_FakeContext`,
and the existing `event_listener.formatter` patch pattern, but set the fake
agent to verbose and the crew to non-verbose so the
`handle_agent_logs_execution` call is still not made.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lib/crewai/tests/core/providers/test_human_input.py`:
- Around line 114-128: The `test_result_not_reshown_when_verbose` regression
only covers the `_ensure_result_displayed()` path where `crew.verbose=True`, but
the same no-op behavior should also be verified when `agent.verbose=True`. Add a
focused async test in `test_human_input.py` using `SyncHumanInputProvider`,
`_FakeContext`, and the existing `event_listener.formatter` patch pattern, but
set the fake agent to verbose and the crew to non-verbose so the
`handle_agent_logs_execution` call is still not made.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 19a5e57d-4b49-4301-9cb1-684a5044b2d3

📥 Commits

Reviewing files that changed from the base of the PR and between ffa5f20 and 9135caf.

📒 Files selected for processing (1)
  • lib/crewai/tests/core/providers/test_human_input.py

HumphreySun98 and others added 3 commits June 24, 2026 15:13
…verbose

With human_input=True the feedback panel asks the operator to review "the
Final Result above", but the result is only rendered when the agent or crew
runs verbose (AgentLogsExecutionEvent and streaming are both verbose-gated).
So a non-verbose human-in-the-loop run prompts the operator to approve output
that was never displayed.

Render the result through the existing console formatter before each feedback
prompt when verbose is off, covering both the sync and async paths and every
feedback round. No-op when verbose to avoid a duplicate panel.

Fixes crewAIInc#6072

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover the async feedback entry path (handle_feedback_async) so the
result-before-prompt ordering and the verbose no-op are protected there too,
matching the sync coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add sync and async cases asserting the result is not re-rendered when the
agent is verbose but the crew is not, complementing the crew-verbose cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@HumphreySun98 HumphreySun98 force-pushed the fix/human-input-show-result-non-verbose branch from a292a23 to 16d8c40 Compare June 24, 2026 20:14
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.

[BUG] human_input=True: the feedback prompt references a "Final Result above" that is never displayed unless verbose=True

1 participant