UAT: ToolRunner.execute() silently ignores target_resource for SPECIFIC environment preference mode — named container routing broken #3826

Open
opened 2026-04-06 06:47:50 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/tool-runner-specific-target-resource
  • Commit Message: fix(runner): pass target_resource to resolver and executor for SPECIFIC environment mode
  • Milestone: Backlog (see note below)
  • Parent Epic: #400

Summary

When a tool declares environment.specific (targeting a named container resource), ToolRunner.execute() in src/cleveragents/tool/runner.py silently ignores the target_resource name and routes to any available container instead. The spec requires that SPECIFIC mode routes to the exact named resource.

What Was Tested

Code-level analysis of ToolRunner.execute() against specification §19499-19507 (Tool-Level Environment Preferences).

Expected Behavior (from spec)

Per specification §19499-19507:

  • environment.specific: Tool targets a specific named resource (e.g., local/api-dev). If the named resource is available and running, the tool is routed there regardless of the general precedence chain.

Actual Behavior

In src/cleveragents/tool/runner.py, lines 291-303:

if pref.mode == EnvironmentPreferenceMode.SPECIFIC:
    # Route to container; the named target_resource identifies
    # which container to use.
    effective_tool_env = "container"
    # TODO: pass pref.target_resource to the resolver /
    # container executor so the specific named resource is
    # selected.  The current resolver and ContainerToolExecutor
    # APIs do not accept a target_resource parameter.
    logger.debug(
        "tool_env_preference.specific_override",
        tool=tool_name,
        target_resource=pref.target_resource,
    )

The target_resource is logged but never passed to the ExecutionEnvironmentResolver or ContainerToolExecutor. The tool is routed to any available container, not the specific named one.

Code Location

  • src/cleveragents/tool/runner.py, lines 291-303
  • The TODO comment explicitly acknowledges this gap

Impact

  • Tools with environment.specific preference are silently routed to the wrong container
  • No error is raised when the specific named container is unavailable
  • Multi-container projects cannot route tools to specific containers
  • The spec's guarantee that SPECIFIC mode routes to the exact named resource is violated

Steps to Reproduce

  1. Register a tool with execution_environment.mode = SPECIFIC and target_resource = "local/api-dev"
  2. Configure a project with multiple container resources
  3. Execute the tool via ToolRunner.execute()
  4. Observe that the tool is routed to any available container, not local/api-dev

Subtasks

  • Add target_resource parameter to ExecutionEnvironmentResolver.resolve_with_precedence() and resolve_with_dag()
  • Add target_resource parameter to ContainerToolExecutor to select the specific named container
  • Update ToolRunner.execute() to pass pref.target_resource to the resolver and executor
  • Raise ContainerUnavailableError when the specific named container is not found
  • Add Behave tests for SPECIFIC mode routing
  • Run all nox sessions and fix any errors

Definition of Done

  • ToolRunner.execute() passes target_resource to the resolver and executor for SPECIFIC mode
  • The specific named container is selected when available
  • ContainerUnavailableError is raised when the specific named container is not found
  • All existing tests pass
  • New Behave tests cover SPECIFIC mode routing
  • All nox stages pass
  • Coverage >= 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.6.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/tool-runner-specific-target-resource` - **Commit Message**: `fix(runner): pass target_resource to resolver and executor for SPECIFIC environment mode` - **Milestone**: Backlog (see note below) - **Parent Epic**: #400 ## Summary When a tool declares `environment.specific` (targeting a named container resource), `ToolRunner.execute()` in `src/cleveragents/tool/runner.py` silently ignores the `target_resource` name and routes to any available container instead. The spec requires that `SPECIFIC` mode routes to the exact named resource. ## What Was Tested Code-level analysis of `ToolRunner.execute()` against specification §19499-19507 (Tool-Level Environment Preferences). ## Expected Behavior (from spec) Per specification §19499-19507: - `environment.specific`: Tool targets a specific named resource (e.g., `local/api-dev`). If the named resource is available and running, the tool is routed there **regardless of the general precedence chain**. ## Actual Behavior In `src/cleveragents/tool/runner.py`, lines 291-303: ```python if pref.mode == EnvironmentPreferenceMode.SPECIFIC: # Route to container; the named target_resource identifies # which container to use. effective_tool_env = "container" # TODO: pass pref.target_resource to the resolver / # container executor so the specific named resource is # selected. The current resolver and ContainerToolExecutor # APIs do not accept a target_resource parameter. logger.debug( "tool_env_preference.specific_override", tool=tool_name, target_resource=pref.target_resource, ) ``` The `target_resource` is logged but **never passed** to the `ExecutionEnvironmentResolver` or `ContainerToolExecutor`. The tool is routed to any available container, not the specific named one. ## Code Location - `src/cleveragents/tool/runner.py`, lines 291-303 - The TODO comment explicitly acknowledges this gap ## Impact - Tools with `environment.specific` preference are silently routed to the wrong container - No error is raised when the specific named container is unavailable - Multi-container projects cannot route tools to specific containers - The spec's guarantee that `SPECIFIC` mode routes to the exact named resource is violated ## Steps to Reproduce 1. Register a tool with `execution_environment.mode = SPECIFIC` and `target_resource = "local/api-dev"` 2. Configure a project with multiple container resources 3. Execute the tool via `ToolRunner.execute()` 4. Observe that the tool is routed to any available container, not `local/api-dev` ## Subtasks - [ ] Add `target_resource` parameter to `ExecutionEnvironmentResolver.resolve_with_precedence()` and `resolve_with_dag()` - [ ] Add `target_resource` parameter to `ContainerToolExecutor` to select the specific named container - [ ] Update `ToolRunner.execute()` to pass `pref.target_resource` to the resolver and executor - [ ] Raise `ContainerUnavailableError` when the specific named container is not found - [ ] Add Behave tests for SPECIFIC mode routing - [ ] Run all `nox` sessions and fix any errors ## Definition of Done - `ToolRunner.execute()` passes `target_resource` to the resolver and executor for SPECIFIC mode - The specific named container is selected when available - `ContainerUnavailableError` is raised when the specific named container is not found - All existing tests pass - New Behave tests cover SPECIFIC mode routing - All nox stages pass - Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
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.

Blocks
#400 Epic: Post-MVP Security
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3826
No description provided.