Skip to content

feat(task): a run's gateway and service-db env overrides travel with it to any runner - #255

Merged
AlexS-scale merged 3 commits into
mainfrom
AlexS/per-run-infra-env-ids
Oct 19, 2026
Merged

AlexS-scale merged 3 commits into
mainfrom
AlexS/per-run-infra-env-ids

Conversation

@AlexS-scale

@AlexS-scale AlexS-scale commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

First step towards task run and eval run always going through the configured [runner] (discussed on #236).

--gateway-env-id and --service-db-env-id set get_config().default_gateway_env_id / default_service_db_env_id in the CLI's own process. A run that executes anywhere else, such as a Temporal or LittleHorse worker or any non-local runner, never sees them.

They now travel like the other per-run overrides:

  • The CLI puts them in context.metadata["user_overrides"] as gateway_env_id and service_db_env_id.
  • Task.run scopes them to the run with a ContextVar (run_env_ids), the same way run_scope scopes store routing.
  • Every place a run picks the gateway or service-db env now reads gateway_env_id(config) / service_db_env_id(config), which returns the run's override, else the configured default. That is four places in the gateway deploy and the local state store, plus the multi-env snapshot restore.

Concurrent runs in one worker each see their own ids, and nothing changes outside a run. agent-env env deploy and the infra-env bootstrap still read the config, because they work outside a run.

Test: two concurrent runs with different overrides each see their own ids, and the defaults are back after them.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issue remains.

Summary

Per-run gateway and service database choices now travel in task metadata instead of changing shared configuration.

  • Task runs now use their own gateway and service-db environment IDs.

The previous and current commits have different merge bases with the target commit, so this review used the full PR diff. No new actionable issues were found. Tests were inspected, not executed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[CLI flags] --> B[Task context metadata]
    B --> C[Task.run]
    C --> D[run_env_ids scope]
    D --> E[Gateway deployment]
    D --> F[Local database setup]
    D --> G[Snapshot restore]
    C --> H[Restore outer choices]
Loading

Reviews (3) · Last reviewed commit: "Merge branch 'main' into AlexS/per-run-i..." · Reviewed by Greptile

@AlexS-scale
AlexS-scale requested a review from a team as a code owner October 19, 2026 16:32
Comment thread src/agent_env/cli/task/run.py
Comment thread tst/unit/config/test_run_env_ids.py Outdated
@AlexS-scale
AlexS-scale merged commit 5d868eb into main Oct 19, 2026
14 checks passed
@AlexS-scale
AlexS-scale deleted the AlexS/per-run-infra-env-ids branch October 19, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants