Fix: Robot Framework test 'Session Tell Appends Message' fails due to exhausted mock side_effect in tell_message helper #8847

Open
opened 2026-04-14 02:36:49 +00:00 by HAL9000 · 2 comments
Owner

Metadata

  • Commit Message: fix(robot): use function side_effect for append_message mock in tell_message helper
  • Branch: fix/robot-session-tell-mock-side-effect

Background and Context

The Robot Framework integration test Session Tell Appends Message in robot/session_cli.robot is failing with a non-zero exit code. The root cause is in the test helper robot/helper_session_cli.py, in the tell_message function.

The tell_message function mocks SessionService.append_message with a side_effect that is a list of two SessionMessage objects:

svc.append_message.side_effect = [
    _mock_message(MessageRole.USER, "Hello", 0),
    _mock_message(MessageRole.ASSISTANT, "Acknowledged: Hello", 1),
]

When unittest.mock is given a list as side_effect, it returns each item in the list in sequence and raises StopIteration once the list is exhausted. The session tell command (in src/cleveragents/cli/commands/session.py) calls service.append_message twice per invocation — once for the USER message and once for the ASSISTANT message. This means the list is fully consumed on the first call to runner.invoke. If the mock is called again for any reason (e.g., retry logic, test framework re-invocation, or future changes to the tell command), a StopIteration exception is raised, causing the test to fail with a non-zero exit code.

The fix is to replace the list side_effect with a function that always returns a valid SessionMessage, making the mock reusable across any number of calls.

Expected Behavior

The Session Tell Appends Message Robot Framework integration test should pass consistently when the integration_tests nox session is run (nox -s integration_tests). The tell_message helper function should use a side_effect function for the append_message mock so that it can be called any number of times without raising StopIteration.

Acceptance Criteria

  • The tell_message function in robot/helper_session_cli.py uses a callable (function) for svc.append_message.side_effect instead of a list.
  • The callable returns a valid SessionMessage on every call, regardless of how many times it is invoked.
  • The Session Tell Appends Message test in robot/session_cli.robot passes when nox -s integration_tests is run.
  • No other tests in the integration_tests nox session are broken by the change.
  • Test coverage remains at or above the project-defined threshold (≥ 97%).

Supporting Information

  • Failing test: Session Tell Appends Message in robot/session_cli.robot
  • Root cause file: robot/helper_session_cli.py, function tell_message
  • Reproduction: Run nox -s integration_tests
  • Relevant production code: src/cleveragents/cli/commands/session.py, function tell (lines ~846–870) — calls service.append_message twice per invocation
  • Suggested fix: Replace the list side_effect with a function:
def _append_side_effect(session_id, role, content):
    return _mock_message(role, content, 0)

svc.append_message.side_effect = _append_side_effect

Subtasks

  • Update tell_message in robot/helper_session_cli.py to use a function for svc.append_message.side_effect
  • Verify the Session Tell Appends Message test passes via nox -s integration_tests
  • Run nox (all default sessions) and fix any errors
  • Verify coverage ≥ 97% via nox -s coverage_report

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (fix(robot): use function side_effect for append_message mock in tell_message helper), followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (fix/robot-session-tell-mock-side-effect).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `fix(robot): use function side_effect for append_message mock in tell_message helper` - **Branch**: `fix/robot-session-tell-mock-side-effect` ## Background and Context The Robot Framework integration test `Session Tell Appends Message` in `robot/session_cli.robot` is failing with a non-zero exit code. The root cause is in the test helper `robot/helper_session_cli.py`, in the `tell_message` function. The `tell_message` function mocks `SessionService.append_message` with a `side_effect` that is a **list** of two `SessionMessage` objects: ```python svc.append_message.side_effect = [ _mock_message(MessageRole.USER, "Hello", 0), _mock_message(MessageRole.ASSISTANT, "Acknowledged: Hello", 1), ] ``` When `unittest.mock` is given a list as `side_effect`, it returns each item in the list in sequence and raises `StopIteration` once the list is exhausted. The `session tell` command (in `src/cleveragents/cli/commands/session.py`) calls `service.append_message` **twice** per invocation — once for the USER message and once for the ASSISTANT message. This means the list is fully consumed on the first call to `runner.invoke`. If the mock is called again for any reason (e.g., retry logic, test framework re-invocation, or future changes to the `tell` command), a `StopIteration` exception is raised, causing the test to fail with a non-zero exit code. The fix is to replace the list `side_effect` with a **function** that always returns a valid `SessionMessage`, making the mock reusable across any number of calls. ## Expected Behavior The `Session Tell Appends Message` Robot Framework integration test should pass consistently when the `integration_tests` nox session is run (`nox -s integration_tests`). The `tell_message` helper function should use a `side_effect` function for the `append_message` mock so that it can be called any number of times without raising `StopIteration`. ## Acceptance Criteria - [ ] The `tell_message` function in `robot/helper_session_cli.py` uses a callable (function) for `svc.append_message.side_effect` instead of a list. - [ ] The callable returns a valid `SessionMessage` on every call, regardless of how many times it is invoked. - [ ] The `Session Tell Appends Message` test in `robot/session_cli.robot` passes when `nox -s integration_tests` is run. - [ ] No other tests in the `integration_tests` nox session are broken by the change. - [ ] Test coverage remains at or above the project-defined threshold (≥ 97%). ## Supporting Information - **Failing test**: `Session Tell Appends Message` in `robot/session_cli.robot` - **Root cause file**: `robot/helper_session_cli.py`, function `tell_message` - **Reproduction**: Run `nox -s integration_tests` - **Relevant production code**: `src/cleveragents/cli/commands/session.py`, function `tell` (lines ~846–870) — calls `service.append_message` twice per invocation - **Suggested fix**: Replace the list `side_effect` with a function: ```python def _append_side_effect(session_id, role, content): return _mock_message(role, content, 0) svc.append_message.side_effect = _append_side_effect ``` ## Subtasks - [ ] Update `tell_message` in `robot/helper_session_cli.py` to use a function for `svc.append_message.side_effect` - [ ] Verify the `Session Tell Appends Message` test passes via `nox -s integration_tests` - [ ] Run `nox` (all default sessions) and fix any errors - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`fix(robot): use function side_effect for append_message mock in tell_message helper`), followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`fix/robot-session-tell-mock-side-effect`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.2.0 milestone 2026-04-14 02:47:53 +00:00
Author
Owner

[GROOMED] Quality analysis complete for issue #8847.

Labels Applied: Type/Bug, Priority/High, State/Unverified, MoSCoW/Must have
Milestone: v3.2.0

Analysis:

  • Issue has proper format: Metadata (Commit Message, Branch) ✓, Background ✓, Acceptance Criteria ✓, Subtasks ✓, Definition of Done ✓
  • Robot Framework test failure is a CI blocker — Priority/High is appropriate
  • Root cause is well-documented (exhausted mock side_effect list)
  • Fix is straightforward and well-specified
  • Assigned to v3.2.0 as integration test health is required for milestone delivery
  • No parent Epic link found — consider linking to a Testing/QA epic if one exists

Automated by CleverAgents Bot
Supervisor: Grooming | Agent: grooming-pool-supervisor
Worker: [AUTO-GROOM-1]

[GROOMED] Quality analysis complete for issue #8847. **Labels Applied**: Type/Bug, Priority/High, State/Unverified, MoSCoW/Must have **Milestone**: v3.2.0 **Analysis**: - Issue has proper format: Metadata (Commit Message, Branch) ✓, Background ✓, Acceptance Criteria ✓, Subtasks ✓, Definition of Done ✓ - Robot Framework test failure is a CI blocker — Priority/High is appropriate - Root cause is well-documented (exhausted mock side_effect list) - Fix is straightforward and well-specified - Assigned to v3.2.0 as integration test health is required for milestone delivery - No parent Epic link found — consider linking to a Testing/QA epic if one exists --- **Automated by CleverAgents Bot** Supervisor: Grooming | Agent: grooming-pool-supervisor Worker: [AUTO-GROOM-1]
Author
Owner

Triage Decision: VERIFIED — MoSCoW/Must Have

Real test failure: Robot Framework test 'Session Tell Appends Message' fails due to exhausted resources. Test failures in the test suite block CI and prevent quality gates from working. This needs to be fixed to restore CI health.

Priority/High — Test failures block CI and quality gates.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Triage Decision: VERIFIED — MoSCoW/Must Have** Real test failure: Robot Framework test 'Session Tell Appends Message' fails due to exhausted resources. Test failures in the test suite block CI and prevent quality gates from working. This needs to be fixed to restore CI health. **Priority/High** — Test failures block CI and quality gates. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8847
No description provided.