feat(execution): add execution environment routing #512

Closed
opened 2026-03-02 16:22:03 +00:00 by freemo · 0 comments
Owner

Metadata

  • Commit Message: feat(execution): add execution environment routing
  • Branch: feature/m6-execution-env-routing

Background and Context

The specification (§Execution > Execution Environment Routing) defines a mechanism for tools to execute either on the host or inside a container. The execution environment is configurable at project, plan, and resource scope with a priority chain: tool-level > plan-level > project-level > default (host). When a container execution environment is selected, the tool runner must route execution through the appropriate container handler rather than executing directly on the host.

Expected Behavior

Users can configure execution environments per project/plan/resource. Tool execution respects the priority chain and routes to the appropriate environment. Default is always host for backward compatibility.

Acceptance Criteria

  • Add ExecutionEnvironment enum (host, container) to domain models.
  • Add execution_environment field to Project, Plan, and resource configuration models.
  • Implement execution environment resolution with priority chain: tool-level > plan-level > project-level > default (host).
  • Wire the tool runner to check execution_environment before execution and route to the container handler when container is selected.
  • Add --execution-environment flag to agents plan use and agents plan execute CLI commands.
  • Add agents project context set execution_environment container for project-level config.
  • When container is selected but no container resource is available, raise a clear error with guidance on how to link a devcontainer resource.

Definition of Done

This issue is complete when:

  • All subtasks below are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Subtasks

  • Code [Jeff]: Add ExecutionEnvironment enum to src/cleveragents/domain/models/core/enums.py.
  • Code [Jeff]: Add execution_environment field to Plan, Project, and resource config models with default host.
  • Code [Jeff]: Implement ExecutionEnvironmentResolver service in src/cleveragents/application/services/ that resolves the effective execution environment using the priority chain.
  • Code [Jeff]: Wire the tool runner (src/cleveragents/tool/runner.py) to consult ExecutionEnvironmentResolver before executing tools.
  • Code [Jeff]: Add --execution-environment flag to agents plan use and agents plan execute in src/cleveragents/cli/commands/plan.py.
  • Code [Jeff]: Add project-level execution environment config via agents project context set.
  • Code [Jeff]: Add error handling for container environment with no available container resource.
  • Docs [Jeff]: Add docs/reference/execution_environment.md documenting the priority chain, configuration, and error scenarios.
  • Tests (Behave) [Jeff]: Add features/execution_environment.feature covering: default host execution, project-level override, plan-level override, tool-level override, priority chain, missing container error.
  • Tests (Robot) [Jeff]: Add robot/execution_environment.robot integration tests for CLI flags and config.
  • Tests (ASV) [Jeff]: Add benchmarks/execution_environment_bench.py for resolution overhead measurement.
  • Quality [Jeff]: Verify coverage >=97% via nox -s coverage_report. If coverage is <97% then review the current unit test coverage report at build/coverage.xml and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improve coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun nox -s coverage_report to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.
  • Quality [Jeff]: Run nox (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.

Parent: #397 (Epic: Server & Autonomy Infrastructure)

## Metadata - **Commit Message**: `feat(execution): add execution environment routing` - **Branch**: `feature/m6-execution-env-routing` ## Background and Context The specification (§Execution > Execution Environment Routing) defines a mechanism for tools to execute either on the host or inside a container. The execution environment is configurable at project, plan, and resource scope with a priority chain: tool-level > plan-level > project-level > default (host). When a container execution environment is selected, the tool runner must route execution through the appropriate container handler rather than executing directly on the host. ## Expected Behavior Users can configure execution environments per project/plan/resource. Tool execution respects the priority chain and routes to the appropriate environment. Default is always `host` for backward compatibility. ## Acceptance Criteria - [ ] Add `ExecutionEnvironment` enum (`host`, `container`) to domain models. - [ ] Add `execution_environment` field to `Project`, `Plan`, and resource configuration models. - [ ] Implement execution environment resolution with priority chain: tool-level > plan-level > project-level > default (host). - [ ] Wire the tool runner to check `execution_environment` before execution and route to the container handler when `container` is selected. - [ ] Add `--execution-environment` flag to `agents plan use` and `agents plan execute` CLI commands. - [ ] Add `agents project context set execution_environment container` for project-level config. - [ ] When `container` is selected but no container resource is available, raise a clear error with guidance on how to link a devcontainer resource. ## Definition of Done This issue is complete when: - All subtasks below are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. ## Subtasks - [ ] Code [Jeff]: Add `ExecutionEnvironment` enum to `src/cleveragents/domain/models/core/enums.py`. - [ ] Code [Jeff]: Add `execution_environment` field to Plan, Project, and resource config models with default `host`. - [ ] Code [Jeff]: Implement `ExecutionEnvironmentResolver` service in `src/cleveragents/application/services/` that resolves the effective execution environment using the priority chain. - [ ] Code [Jeff]: Wire the tool runner (`src/cleveragents/tool/runner.py`) to consult `ExecutionEnvironmentResolver` before executing tools. - [ ] Code [Jeff]: Add `--execution-environment` flag to `agents plan use` and `agents plan execute` in `src/cleveragents/cli/commands/plan.py`. - [ ] Code [Jeff]: Add project-level execution environment config via `agents project context set`. - [ ] Code [Jeff]: Add error handling for container environment with no available container resource. - [ ] Docs [Jeff]: Add `docs/reference/execution_environment.md` documenting the priority chain, configuration, and error scenarios. - [ ] Tests (Behave) [Jeff]: Add `features/execution_environment.feature` covering: default host execution, project-level override, plan-level override, tool-level override, priority chain, missing container error. - [ ] Tests (Robot) [Jeff]: Add `robot/execution_environment.robot` integration tests for CLI flags and config. - [ ] Tests (ASV) [Jeff]: Add `benchmarks/execution_environment_bench.py` for resolution overhead measurement. - [ ] Quality [Jeff]: Verify coverage >=97% via `nox -s coverage_report`. If coverage is &lt;97% then review the current unit test coverage report at `build/coverage.xml` and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improve coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `nox -s coverage_report` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%. - [ ] Quality [Jeff]: Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across **entire** code base, do not ignore any failure even if it seems unrelated to this commit, fix it. Parent: #397 (Epic: Server &amp; Autonomy Infrastructure)
freemo added this to the v3.5.0 milestone 2026-03-02 16:22:40 +00:00
freemo self-assigned this 2026-03-02 16:27:46 +00:00
freemo 2026-03-03 19:54:13 +00:00
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#512
No description provided.