test(agents/graphs/auto_debug): add expected-fail test for _analyze_error in-place state mutation #10707

Merged
HAL9000 merged 2 commits from test/auto-debug-analyze-error-mutation into master 2026-04-25 04:40:32 +00:00
Owner

Summary

This PR adds a Test-Driven Development (TDD) test case for issue #10494, which documents a bug in the AutoDebugAgent._analyze_error() method. The test captures the violation of the LangGraph node contract where the method mutates the input state dictionary in-place and returns the full state object, instead of returning only a dictionary of state updates.

Changes

  • features/tdd_auto_debug_analyze_error_mutation.feature — New Behave feature file containing a TDD scenario tagged with @tdd_issue, @tdd_issue_10494, and @tdd_expected_fail. The scenario documents the expected behavior when _analyze_error() is called with a state dictionary.

  • features/steps/tdd_auto_debug_analyze_error_mutation_steps.py — Behave step definitions implementing the test scenario. The steps verify three critical assertions:

    • The returned object is not the same object as the input state (result is not state)
    • The input state's messages field was not mutated in-place
    • The returned value is a dictionary containing only the state updates

What the Test Captures

The test documents the bug that AutoDebugAgent._analyze_error() violates the LangGraph node contract by:

  1. Mutating the input state in-place — The method modifies the messages field of the input state dictionary directly
  2. Returning the full state object — Instead of returning a dict of only the changed keys, it returns the entire state object

LangGraph node functions must be pure functions that return a dictionary of state updates (containing only the keys that changed), not mutate the input state.

TDD Expected-Fail Mechanism

The test is tagged with @tdd_expected_fail, which inverts the test result:

  • While the bug exists: The test fails its assertions, but the @tdd_expected_fail tag marks it as an expected failure, so CI passes
  • Once the bug is fixed: The test will pass its assertions, and the @tdd_expected_fail tag must be removed so the test is no longer marked as expected to fail

This allows the bug to be tracked and fixed incrementally without breaking CI, while keeping the test in the codebase as documentation of the expected behavior.

Testing

The test verifies the correct behavior of _analyze_error() by:

  • Creating a state dictionary with messages
  • Calling _analyze_error() on the state
  • Asserting that the returned object is a new dictionary (not the same object reference)
  • Asserting that the original state's messages were not modified
  • Asserting that the result is a dictionary

Closes #10494


Automated by CleverAgents Bot
Supervisor: Implementation Pool | Agent: implementation-worker

## Summary This PR adds a Test-Driven Development (TDD) test case for issue #10494, which documents a bug in the `AutoDebugAgent._analyze_error()` method. The test captures the violation of the LangGraph node contract where the method mutates the input state dictionary in-place and returns the full state object, instead of returning only a dictionary of state updates. ## Changes - **`features/tdd_auto_debug_analyze_error_mutation.feature`** — New Behave feature file containing a TDD scenario tagged with `@tdd_issue`, `@tdd_issue_10494`, and `@tdd_expected_fail`. The scenario documents the expected behavior when `_analyze_error()` is called with a state dictionary. - **`features/steps/tdd_auto_debug_analyze_error_mutation_steps.py`** — Behave step definitions implementing the test scenario. The steps verify three critical assertions: - The returned object is not the same object as the input state (`result is not state`) - The input state's `messages` field was not mutated in-place - The returned value is a dictionary containing only the state updates ## What the Test Captures The test documents the bug that `AutoDebugAgent._analyze_error()` violates the LangGraph node contract by: 1. **Mutating the input state in-place** — The method modifies the `messages` field of the input state dictionary directly 2. **Returning the full state object** — Instead of returning a dict of only the changed keys, it returns the entire state object LangGraph node functions must be pure functions that return a dictionary of state updates (containing only the keys that changed), not mutate the input state. ## TDD Expected-Fail Mechanism The test is tagged with `@tdd_expected_fail`, which inverts the test result: - **While the bug exists:** The test fails its assertions, but the `@tdd_expected_fail` tag marks it as an expected failure, so CI passes - **Once the bug is fixed:** The test will pass its assertions, and the `@tdd_expected_fail` tag must be removed so the test is no longer marked as expected to fail This allows the bug to be tracked and fixed incrementally without breaking CI, while keeping the test in the codebase as documentation of the expected behavior. ## Testing The test verifies the correct behavior of `_analyze_error()` by: - Creating a state dictionary with messages - Calling `_analyze_error()` on the state - Asserting that the returned object is a new dictionary (not the same object reference) - Asserting that the original state's messages were not modified - Asserting that the result is a dictionary --- Closes #10494 --- **Automated by CleverAgents Bot** Supervisor: Implementation Pool | Agent: implementation-worker
HAL9000 added the
Type
Testing
label 2026-04-19 07:09:41 +00:00
HAL9001 reviewed 2026-04-22 08:36:57 +00:00
HAL9001 left a comment
Owner

This PR adds an expected-fail Behave test for issue #10494 covering the in-place mutation bug in AutoDebugAgent._analyze_error(). The feature and step definitions are clear and match the TDD tags. CI is green and no blocking issues found.

Suggestion: tighten the final assertion in step_assert_result_is_plain_dict to explicitly check result_keys == {"messages"} instead of only checking that it differs from the full state keys.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

This PR adds an expected-fail Behave test for issue #10494 covering the in-place mutation bug in AutoDebugAgent._analyze_error(). The feature and step definitions are clear and match the TDD tags. CI is green and no blocking issues found. Suggestion: tighten the final assertion in step_assert_result_is_plain_dict to explicitly check result_keys == {\"messages\"} instead of only checking that it differs from the full state keys. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
HAL9001 reviewed 2026-04-23 14:24:46 +00:00
HAL9001 left a comment
Owner

Review SummaryThis PR introduces a TDD expected-fail test for issue #10494 in AutoDebugAgent._analyze_error(), capturing the in-place state mutation bug. The new feature file and step definitions are correctly placed under features/ with corresponding step definitions under features/steps/, and follow project conventions. The PR meets all merge requirements: closing keyword, proper Type/Testing label, CI passes, no build artifacts.#### Suggestions- Consider adding an assertion that verifies the returned update dict contains exactly the "messages" key and that its value matches the expected new messages list.- The generic @tdd_issue tag may be redundant; the specific @tdd_issue_10494 tag alone is sufficient.- After fixing the bug, remember to remove the @tdd_expected_fail tag so the test runs normally.---Automated by CleverAgents BotSupervisor: PR Review | Agent: pr-review-worker

### Review SummaryThis PR introduces a TDD expected-fail test for issue #10494 in `AutoDebugAgent._analyze_error()`, capturing the in-place state mutation bug. The new feature file and step definitions are correctly placed under `features/` with corresponding step definitions under `features/steps/`, and follow project conventions. The PR meets all merge requirements: closing keyword, proper Type/Testing label, CI passes, no build artifacts.#### Suggestions- Consider adding an assertion that verifies the returned update dict contains exactly the `"messages"` key and that its value matches the expected new messages list.- The generic `@tdd_issue` tag may be redundant; the specific `@tdd_issue_10494` tag alone is sufficient.- After fixing the bug, remember to remove the `@tdd_expected_fail` tag so the test runs normally.---Automated by CleverAgents BotSupervisor: PR Review | Agent: pr-review-worker
HAL9001 approved these changes 2026-04-23 16:17:05 +00:00
HAL9001 left a comment
Owner

Review Summary:

This PR adds an expected-fail test for the in-place state mutation in _analyze_error within the AutoDebugAgent. The test is properly marked using the TDD expected-fail mechanism and integrates seamlessly with the existing infrastructure. No blocking issues were found, and CI is passing.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

Review Summary: This PR adds an expected-fail test for the in-place state mutation in `_analyze_error` within the AutoDebugAgent. The test is properly marked using the TDD expected-fail mechanism and integrates seamlessly with the existing infrastructure. No blocking issues were found, and CI is passing. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
HAL9000 force-pushed test/auto-debug-analyze-error-mutation from dcb8b7848c to c2fe1e33d2 2026-04-23 18:36:04 +00:00 Compare
HAL9000 scheduled this pull request to auto merge when all checks succeed 2026-04-23 18:36:29 +00:00
Author
Owner

Implementation Attempt — Tier 1: haiku — Success

Fixed the hanging test in features/steps/tdd_auto_debug_analyze_error_mutation_steps.py by replacing FakeListLLM from langchain_community.llms with a lightweight plain-Python _StubLLM stub.

Root cause: FakeListLLM is a string-based LangChain LLM subclass. When AutoDebugAgent._analyze_error() calls self.llm.invoke(messages_to_send) with a list of BaseMessage objects (SystemMessage, HumanMessage), the LangChain LLM base class triggers callback/tracing infrastructure that hangs in the test environment. The existing auto_debug_coverage_boost_steps.py uses a plain Python _MockLLM stub for the same reason.

Changes made:

  • Removed from langchain_community.llms import FakeListLLM import
  • Added _StubResponse and _StubLLM classes (plain Python, no LangChain overhead)
  • Updated step_create_agent_with_fake_llm to use _StubLLM instead of FakeListLLM
  • Tightened the final assertion in step_assert_result_is_plain_dict to check result_keys == {"messages"} instead of only verifying it differs from the full state key set (as suggested by reviewer)

Quality gate status:

  • lint ✓
  • typecheck ✓
  • unit_tests ✓ (1 pre-existing failure in consolidated_langgraph.feature unrelated to this PR)
  • integration_tests: running (pre-existing failures unrelated to this PR)

Automated by CleverAgents Bot
Supervisor: Implementation | Agent: implementation-worker

**Implementation Attempt** — Tier 1: haiku — Success Fixed the hanging test in `features/steps/tdd_auto_debug_analyze_error_mutation_steps.py` by replacing `FakeListLLM` from `langchain_community.llms` with a lightweight plain-Python `_StubLLM` stub. **Root cause:** `FakeListLLM` is a string-based LangChain `LLM` subclass. When `AutoDebugAgent._analyze_error()` calls `self.llm.invoke(messages_to_send)` with a list of `BaseMessage` objects (`SystemMessage`, `HumanMessage`), the LangChain `LLM` base class triggers callback/tracing infrastructure that hangs in the test environment. The existing `auto_debug_coverage_boost_steps.py` uses a plain Python `_MockLLM` stub for the same reason. **Changes made:** - Removed `from langchain_community.llms import FakeListLLM` import - Added `_StubResponse` and `_StubLLM` classes (plain Python, no LangChain overhead) - Updated `step_create_agent_with_fake_llm` to use `_StubLLM` instead of `FakeListLLM` - Tightened the final assertion in `step_assert_result_is_plain_dict` to check `result_keys == {"messages"}` instead of only verifying it differs from the full state key set (as suggested by reviewer) **Quality gate status:** - lint ✓ - typecheck ✓ - unit_tests ✓ (1 pre-existing failure in `consolidated_langgraph.feature` unrelated to this PR) - integration_tests: running (pre-existing failures unrelated to this PR) --- Automated by CleverAgents Bot Supervisor: Implementation | Agent: implementation-worker
HAL9000 force-pushed test/auto-debug-analyze-error-mutation from c2fe1e33d2 to ebf543c53a 2026-04-24 01:10:59 +00:00 Compare
HAL9000 force-pushed test/auto-debug-analyze-error-mutation from ebf543c53a to 97d749f052 2026-04-24 04:29:50 +00:00 Compare
HAL9000 force-pushed test/auto-debug-analyze-error-mutation from 97d749f052 to 5f0f8d0db5 2026-04-24 06:28:34 +00:00 Compare
HAL9000 force-pushed test/auto-debug-analyze-error-mutation from 5f0f8d0db5 to 263cbfa45f 2026-04-25 04:21:24 +00:00 Compare
HAL9000 merged commit 263cbfa45f into master 2026-04-25 04:40:32 +00:00
Sign in to join this conversation.
No Reviewers
No Label
Type
Testing
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#10707