fix(runtime): add input validation, credential safety, and proper error propagation #39

Closed
opened 2026-06-09 14:49:32 +00:00 by CoreRasurae · 0 comments
Member

Metadata

Commit Message: fix(runtime): add input validation, credential safety, and proper error propagation
Branch: fix/master-borked

Background and context

The runtime.py Executor class was missing input validation on constructor parameters and credential safety checks. Additionally, error handling in _execute_llm wrapped exceptions in the wrong error type (ConfigurationError instead of ExecutionError) and agents were not cleaned up after execution. The _execute_graph path did not pass credentials to AgentFactory, and the message router node in nodes.py had a hardcoded default routing to workflow_controller that could cause incorrect graph behavior.

Current behavior

  • Executor accepts invalid constructor parameters silently (non-dict config, credentials, limits, pricing)
  • LLM agent failures raise ConfigurationError instead of ExecutionError
  • No agent cleanup occurs after LLM execution (resource leak)
  • Graph execution does not pass credentials to AgentFactory (agent creation may fail)
  • Message router nodes default-routed to workflow_controller when no rules configured

Expected behavior

  • Executor constructor validates all parameter types and raises ConfigurationError for invalid inputs
  • LLM execution failures raise ExecutionError with the original exception suppressed
  • Agents are always cleaned up (in a finally block) after LLM execution
  • Credentials are passed through to AgentFactory for graph agent creation
  • Message router nodes with no rules return empty dict instead of default routing

Acceptance criteria

  • Executor raises ConfigurationError when config is not a dict
  • Executor raises ConfigurationError when credentials/limits/pricing are wrong type
  • _execute_llm raises ExecutionError for agent failures
  • _execute_llm cleans up agent in finally block
  • _execute_graph passes credentials to AgentFactory
  • Message router node with no rules returns empty dict

Subtasks

  • Add input validation to Executor constructor
  • Fix credential access safety with None check
  • Change LLM error wrapping to ExecutionError
  • Add agent cleanup in finally block
  • Pass credentials to AgentFactory in _execute_graph
  • Allow known exception types to propagate in graph execution
  • Remove default workflow_controller routing in message router nodes
  • Tests (Behave): BDD unit tests for runtime edge cases
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

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 matches the Commit Message in Metadata exactly.
  • The commit is pushed to the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a PR to master, reviewed, and merged.
## Metadata Commit Message: fix(runtime): add input validation, credential safety, and proper error propagation Branch: fix/master-borked ## Background and context The `runtime.py` Executor class was missing input validation on constructor parameters and credential safety checks. Additionally, error handling in `_execute_llm` wrapped exceptions in the wrong error type (`ConfigurationError` instead of `ExecutionError`) and agents were not cleaned up after execution. The `_execute_graph` path did not pass credentials to `AgentFactory`, and the message router node in `nodes.py` had a hardcoded default routing to `workflow_controller` that could cause incorrect graph behavior. ## Current behavior - Executor accepts invalid constructor parameters silently (non-dict config, credentials, limits, pricing) - LLM agent failures raise `ConfigurationError` instead of `ExecutionError` - No agent cleanup occurs after LLM execution (resource leak) - Graph execution does not pass credentials to AgentFactory (agent creation may fail) - Message router nodes default-routed to `workflow_controller` when no rules configured ## Expected behavior - Executor constructor validates all parameter types and raises `ConfigurationError` for invalid inputs - LLM execution failures raise `ExecutionError` with the original exception suppressed - Agents are always cleaned up (in a finally block) after LLM execution - Credentials are passed through to AgentFactory for graph agent creation - Message router nodes with no rules return empty dict instead of default routing ## Acceptance criteria - `Executor` raises `ConfigurationError` when config is not a dict - `Executor` raises `ConfigurationError` when credentials/limits/pricing are wrong type - `_execute_llm` raises `ExecutionError` for agent failures - `_execute_llm` cleans up agent in finally block - `_execute_graph` passes credentials to AgentFactory - Message router node with no rules returns empty dict ## Subtasks - [x] Add input validation to Executor constructor - [x] Fix credential access safety with None check - [x] Change LLM error wrapping to ExecutionError - [x] Add agent cleanup in finally block - [x] Pass credentials to AgentFactory in _execute_graph - [x] Allow known exception types to propagate in graph execution - [x] Remove default workflow_controller routing in message router nodes - [x] Tests (Behave): BDD unit tests for runtime edge cases - [ ] Verify coverage >=97% via nox -s coverage_report - [ ] Run nox (all default sessions), fix any errors ## 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 matches the Commit Message in Metadata exactly. - The commit is pushed to the branch matching the Branch in Metadata exactly. - The commit is submitted as a PR to master, reviewed, and merged.
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.

Reference
cleveragents/cleveractors-core#39
No description provided.