UAT: GRAPH actor conditional nodes use simple field/equals check instead of Python expression evaluation per spec #5477

Open
opened 2026-04-09 06:58:02 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area

Actor System Compilation — GRAPH-type actor conditional node execution

What Was Tested

Code-level analysis of src/cleveragents/langgraph/nodes.py against the specification's conditional node behavior.

Expected Behavior (from spec)

Per docs/specification.md line 20558, conditional nodes use Python expressions for routing:

| `conditional` | `conditions[].check`, `conditions[].route_to` | Routes based on state conditions (Python expressions) |

The spec also states (line 20567): "condition: Python expression for conditional routing."

The EdgeDefinition in schema.py has a condition field described as "Optional Python expression for conditional routing."

Actual Behavior (from code)

src/cleveragents/langgraph/nodes.py lines 292-305 implement _execute_conditional() with a simple field/equals check:

async def _execute_conditional(self, state: GraphState) -> dict[str, Any]:
    condition = self.config.condition or {}
    field = condition.get("field")
    expected = condition.get("equals")
    result = False
    if field:
        for msg in reversed(state.messages):
            if msg.get("role") == "assistant" and field in msg:
                result = msg.get(field) == expected
                break
    return {
        "condition_result": result,
        "metadata": {"conditional_edges_used": True},
    }

This implementation:

  1. Only supports a simple field == expected check (not arbitrary Python expressions)
  2. Only searches through state.messages (not the full graph state)
  3. Does not evaluate the conditions[].check Python expressions described in the spec
  4. Does not implement the conditions[].route_to routing logic

The evaluate_edge_condition() method (lines 335-343) also only supports equals checks, not Python expression evaluation.

Impact

  • Conditional routing in GRAPH actors is severely limited — only simple equality checks work.
  • Complex routing logic (e.g., state.get('error_count') > 3, len(state.messages) > 10, state.metadata.get('confidence') < 0.5) cannot be expressed.
  • The spec's conditions[].check Python expression syntax is not supported.
  • This limits the expressiveness of GRAPH actor workflows significantly.

Code Location

  • src/cleveragents/langgraph/nodes.py lines 292-305 (_execute_conditional())
  • src/cleveragents/langgraph/nodes.py lines 335-343 (evaluate_edge_condition())
  • src/cleveragents/actor/schema.py lines 393-396 (EdgeDefinition.condition field)

Fix Required

Implement Python expression evaluation for conditional routing:

  1. Parse the condition string as a Python expression
  2. Evaluate it against the current GraphState using eval() in a sandboxed context
  3. Support the conditions[].check / conditions[].route_to pattern from the spec
  4. Use ast.literal_eval() or a sandboxed evaluator for security

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report ### Feature Area Actor System Compilation — GRAPH-type actor conditional node execution ### What Was Tested Code-level analysis of `src/cleveragents/langgraph/nodes.py` against the specification's conditional node behavior. ### Expected Behavior (from spec) Per `docs/specification.md` line 20558, conditional nodes use Python expressions for routing: ``` | `conditional` | `conditions[].check`, `conditions[].route_to` | Routes based on state conditions (Python expressions) | ``` The spec also states (line 20567): "condition: Python expression for conditional routing." The `EdgeDefinition` in `schema.py` has a `condition` field described as "Optional Python expression for conditional routing." ### Actual Behavior (from code) `src/cleveragents/langgraph/nodes.py` lines 292-305 implement `_execute_conditional()` with a simple field/equals check: ```python async def _execute_conditional(self, state: GraphState) -> dict[str, Any]: condition = self.config.condition or {} field = condition.get("field") expected = condition.get("equals") result = False if field: for msg in reversed(state.messages): if msg.get("role") == "assistant" and field in msg: result = msg.get(field) == expected break return { "condition_result": result, "metadata": {"conditional_edges_used": True}, } ``` This implementation: 1. Only supports a simple `field == expected` check (not arbitrary Python expressions) 2. Only searches through `state.messages` (not the full graph state) 3. Does not evaluate the `conditions[].check` Python expressions described in the spec 4. Does not implement the `conditions[].route_to` routing logic The `evaluate_edge_condition()` method (lines 335-343) also only supports `equals` checks, not Python expression evaluation. ### Impact - Conditional routing in GRAPH actors is severely limited — only simple equality checks work. - Complex routing logic (e.g., `state.get('error_count') > 3`, `len(state.messages) > 10`, `state.metadata.get('confidence') < 0.5`) cannot be expressed. - The spec's `conditions[].check` Python expression syntax is not supported. - This limits the expressiveness of GRAPH actor workflows significantly. ### Code Location - `src/cleveragents/langgraph/nodes.py` lines 292-305 (`_execute_conditional()`) - `src/cleveragents/langgraph/nodes.py` lines 335-343 (`evaluate_edge_condition()`) - `src/cleveragents/actor/schema.py` lines 393-396 (`EdgeDefinition.condition` field) ### Fix Required Implement Python expression evaluation for conditional routing: 1. Parse the `condition` string as a Python expression 2. Evaluate it against the current `GraphState` using `eval()` in a sandboxed context 3. Support the `conditions[].check` / `conditions[].route_to` pattern from the spec 4. Use `ast.literal_eval()` or a sandboxed evaluator for security --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

🏷️ Label Fix Applied by Backlog Groomer

The State/Verified label has been added to this issue.

Reason: During a routine backlog grooming pass, this issue was found to have Type/Bug and a Priority/ label but was missing a State/* label entirely — a violation of the CONTRIBUTING.md requirement that every issue must have exactly one State/ label.

Since this issue has been triaged with a priority and type, State/Verified is the appropriate state: the issue has been confirmed as legitimate and is now part of the active backlog.

No other changes were made.


Automated by CleverAgents Bot
Supervisor: Label Management | Agent: forgejo-label-manager

## 🏷️ Label Fix Applied by Backlog Groomer The `State/Verified` label has been added to this issue. **Reason**: During a routine backlog grooming pass, this issue was found to have `Type/Bug` and a `Priority/` label but was missing a `State/*` label entirely — a violation of the CONTRIBUTING.md requirement that every issue must have exactly one `State/` label. Since this issue has been triaged with a priority and type, `State/Verified` is the appropriate state: the issue has been confirmed as legitimate and is now part of the active backlog. No other changes were made. --- **Automated by CleverAgents Bot** Supervisor: Label Management | Agent: forgejo-label-manager
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#5477
No description provided.