UAT: Tool-level environment.specific preference ignores target_resource — routes to any available container instead of the named one #5517

Open
opened 2026-04-09 07:11:15 +00:00 by HAL9000 · 1 comment
Owner

Summary

When a tool declares execution_environment.mode = "specific" with a target_resource (e.g., local/api-dev), the ToolRunner acknowledges the preference but contains a TODO comment admitting it does NOT pass target_resource to the resolver or container executor. The tool is routed to any available container rather than the specifically named one.

What Was Tested

Code-level analysis of:

  • src/cleveragents/tool/runner.pyToolRunner.execute(), lines 291-303
  • src/cleveragents/domain/models/core/execution_environment_preference.pyExecutionEnvironmentPreference
  • src/cleveragents/application/services/execution_environment_resolver.py — resolver APIs

Expected Behavior (from spec)

Per docs/specification.md §Tool-Level Environment Preferences (line 19536):

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.

The tool must execute inside the specifically named container resource, not just any container.

Actual Behavior

In 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 used. The tool is routed to ExecutionEnvironment.CONTAINER (any container), not the specific named resource. If multiple containers are linked to a project, the wrong one may be selected.

Code Location

  • src/cleveragents/tool/runner.py, lines 291-303 (TODO comment)
  • src/cleveragents/application/services/execution_environment_resolver.pyresolve_with_precedence() has no target_resource parameter
  • src/cleveragents/tool/container_executor.pyContainerConfig has no target_resource field

Impact

  • Tools with environment.specific preference are silently routed to the wrong container when multiple containers exist
  • The target_resource field in ExecutionEnvironmentPreference is effectively dead code
  • Workflows relying on tool-specific container routing (e.g., a linter that must run in local/lint-container) will silently run in a different container
  • No error is raised — the failure is completely silent

Suggested Fix

  1. Add target_resource: str | None parameter to ExecutionEnvironmentResolver.resolve_with_precedence() and resolve_with_dag()
  2. Add target_resource: str | None to ContainerToolExecutor or pass it as a parameter to execute_tool()
  3. In ToolRunner.execute(), pass pref.target_resource through the resolution chain
  4. In ContainerToolExecutor._devcontainer_target_args(), use the target resource name to select the correct container

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

## Summary When a tool declares `execution_environment.mode = "specific"` with a `target_resource` (e.g., `local/api-dev`), the `ToolRunner` acknowledges the preference but contains a `TODO` comment admitting it does NOT pass `target_resource` to the resolver or container executor. The tool is routed to any available container rather than the specifically named one. ## What Was Tested Code-level analysis of: - `src/cleveragents/tool/runner.py` — `ToolRunner.execute()`, lines 291-303 - `src/cleveragents/domain/models/core/execution_environment_preference.py` — `ExecutionEnvironmentPreference` - `src/cleveragents/application/services/execution_environment_resolver.py` — resolver APIs ## Expected Behavior (from spec) Per `docs/specification.md` §Tool-Level Environment Preferences (line 19536): > `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**. The tool must execute inside the **specifically named** container resource, not just any container. ## Actual Behavior In `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 used**. The tool is routed to `ExecutionEnvironment.CONTAINER` (any container), not the specific named resource. If multiple containers are linked to a project, the wrong one may be selected. ## Code Location - `src/cleveragents/tool/runner.py`, lines 291-303 (TODO comment) - `src/cleveragents/application/services/execution_environment_resolver.py` — `resolve_with_precedence()` has no `target_resource` parameter - `src/cleveragents/tool/container_executor.py` — `ContainerConfig` has no `target_resource` field ## Impact - Tools with `environment.specific` preference are silently routed to the wrong container when multiple containers exist - The `target_resource` field in `ExecutionEnvironmentPreference` is effectively dead code - Workflows relying on tool-specific container routing (e.g., a linter that must run in `local/lint-container`) will silently run in a different container - No error is raised — the failure is completely silent ## Suggested Fix 1. Add `target_resource: str | None` parameter to `ExecutionEnvironmentResolver.resolve_with_precedence()` and `resolve_with_dag()` 2. Add `target_resource: str | None` to `ContainerToolExecutor` or pass it as a parameter to `execute_tool()` 3. In `ToolRunner.execute()`, pass `pref.target_resource` through the resolution chain 4. In `ContainerToolExecutor._devcontainer_target_args()`, use the target resource name to select the correct container --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.6.0 milestone 2026-04-09 07:11:45 +00:00
Author
Owner

Hierarchical Compliance Fix: This issue was detected as an orphan (no parent Epic).

Solution: Linked to Epic #5504 (Container Tool Execution — Docker/Podman Tool Runner) as this bug is directly related to container tool routing and target_resource resolution.

Hierarchy: Issue #5517 → Epic #5504 → Legendary #4945


Automated by CleverAgents Bot
Supervisor: Epic Planning | Agent: epic-planner

**Hierarchical Compliance Fix**: This issue was detected as an orphan (no parent Epic). **Solution**: Linked to Epic #5504 (Container Tool Execution — Docker/Podman Tool Runner) as this bug is directly related to container tool routing and target_resource resolution. **Hierarchy**: Issue #5517 → Epic #5504 → Legendary #4945 --- **Automated by CleverAgents Bot** Supervisor: Epic Planning | Agent: epic-planner
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/cleveragents-core#5517
No description provided.