Skip to content

Commit c90d1cc

Browse files
committed
fix(agents): apply agent manifest settings per sandbox
The agent launcher applied manifest settings with `settings set --global`, so every gator launch switched proposal_approval_mode to auto for the whole gateway. Apply them to the launched sandbox after creation instead. If a gateway-global value already manages a key, warn and leave it in effect. Related to NVIDIA#3469. Signed-off-by: Jim Meyer <[email protected]>
1 parent 50a3237 commit c90d1cc

3 files changed

Lines changed: 28 additions & 18 deletions

File tree

‎scripts/agents/README.md‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sections:
4747
- `runtime`: in-sandbox run mode (`once` or `watch`), watch poll interval, and
4848
transient failure logging threshold.
4949
- `profile_paths`: ordered directories to scan for provider profile YAML files.
50-
- `settings`: gateway settings to apply before launch.
50+
- `settings`: sandbox-scoped settings to apply after the sandbox is created.
5151
- `providers`: provider instances to create or update, credential sources, and
5252
optional refresh configuration.
5353
- `skills`: files to inject into the sandbox payload.
@@ -82,20 +82,22 @@ Manifest paths support these prefixes:
8282
9. Query the gateway's compute driver, then build a temporary image context
8383
with its Docker or Podman image store. The image bakes the rendered payload
8484
into `/etc/openshell/agent-payload`.
85-
10. Apply manifest-declared gateway settings.
86-
11. Resolve provider profile IDs by scanning `profile_paths` in order.
87-
12. Import each provider profile into the gateway. If an active profile already
85+
10. Resolve provider profile IDs by scanning `profile_paths` in order.
86+
11. Import each provider profile into the gateway. If an active profile already
8887
exists, the launcher keeps going and uses it.
89-
13. Resolve provider credentials from host commands, JSON files, or literal
88+
12. Resolve provider credentials from host commands, JSON files, or literal
9089
manifest values.
91-
14. Create or update each provider instance and attach every selected provider
90+
13. Create or update each provider instance and attach every selected provider
9291
to the sandbox.
93-
15. Configure and rotate refresh-backed provider credentials when declared by
92+
14. Configure and rotate refresh-backed provider credentials when declared by
9493
the manifest.
95-
16. Run `openshell sandbox create` from the resulting image reference, with the
94+
15. Run `openshell sandbox create` from the resulting image reference, with the
9695
runtime entrypoint persisted as the detached canonical main process.
97-
17. Mark the sandbox ephemeral unless `--keep` was supplied, allowing the
96+
16. Mark the sandbox ephemeral unless `--keep` was supplied, allowing the
9897
gateway to delete it after the canonical process exits.
98+
17. Apply manifest-declared settings to the new sandbox. The launcher never
99+
changes gateway-global settings. A gateway-global value for the same key
100+
takes precedence, and the launcher warns instead of overriding it.
99101
18. Inside the sandbox, run `/etc/openshell/agent-payload/runtime/entrypoint.sh`.
100102
19. The runtime entrypoint starts
101103
`/etc/openshell/agent-payload/runtime/supervisor.sh`.

‎scripts/agents/gator/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Use `--harness codex` to select Codex explicitly. Other harness names are reject
9898

9999
Use `--codex-bin "$(command -v codex)"` only when the host executable is compatible with the sandbox OS and architecture.
100100

101-
The manifest-driven launcher at `scripts/agents/run.sh` reads `agent.yaml`, which defines the versioned immutable payload, prompt template, provider profile IDs, provider credential sources, gateway settings, skills, subagents, supporting resources, sandbox defaults, runtime mode, and harness defaults. The shared sandbox entrypoint at `scripts/agents/runtime/entrypoint.sh` starts the in-sandbox supervisor, which invokes the selected harness adapter for bounded cycles.
101+
The manifest-driven launcher at `scripts/agents/run.sh` reads `agent.yaml`, which defines the versioned immutable payload, prompt template, provider profile IDs, provider credential sources, sandbox settings, skills, subagents, supporting resources, sandbox defaults, runtime mode, and harness defaults. The shared sandbox entrypoint at `scripts/agents/runtime/entrypoint.sh` starts the in-sandbox supervisor, which invokes the selected harness adapter for bounded cycles.
102102

103103
The launcher:
104104

@@ -109,7 +109,7 @@ The launcher:
109109
- For `--harness codex`, imports `providers/codex-gator.yaml`, creates or updates the `codex-gator` provider from `$HOME/.codex/auth.json`, and stores the refresh token as gateway-only refresh material.
110110
- For `--harness codex`, configures gateway-managed refresh for `CODEX_AUTH_ACCESS_TOKEN` and rotates it before launching the sandbox.
111111
- Passes the non-secret Codex account ID from host auth as `CODEX_ACCOUNT_ID`. The harness writes it literally into `auth.json` for local workspace discovery; access tokens remain opaque provider placeholders and refresh tokens remain gateway-only.
112-
- Enables `agent_policy_proposals_enabled` and `proposal_approval_mode=auto` at gateway scope.
112+
- Enables `agent_policy_proposals_enabled` and `proposal_approval_mode=auto` on the gator sandbox only. Gateway-global values for these keys take precedence; the launcher does not change them.
113113
- Uses the gator image policy copied to `/etc/openshell/policy.yaml`.
114114
- Installs the gator-specific `gh` wrapper from `gator/bin/gh` as `/usr/local/bin/gh` to fail closed when same-head-SHA history cannot be checked, prevent duplicate dispositions, and require versioned review payloads.
115115
- Installs `gator/bin/review-feedback-ledger` as `/usr/local/bin/review-feedback-ledger` so reviews receive tree- and patch-aware scope, prior summaries and findings, resolution state, convergence telemetry, and the three-round Warning budget.

‎scripts/agents/run.sh‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -735,13 +735,6 @@ if [[ "$BUILD_ONLY" == 1 ]]; then
735735
exit 0
736736
fi
737737

738-
log "Configuring gateway settings."
739-
for ((setting_index = 0; setting_index < SETTING_COUNT; setting_index++)); do
740-
key_var="SETTING_${setting_index}_KEY"
741-
value_var="SETTING_${setting_index}_VALUE"
742-
openshell_cmd settings set --global --key "${!key_var}" --value "${!value_var}" --yes >/dev/null
743-
done
744-
745738
PROVIDER_ARGS=()
746739
for ((provider_index = 0; provider_index < PROVIDER_COUNT; provider_index++)); do
747740
name_var="PROVIDER_${provider_index}_NAME"
@@ -864,3 +857,18 @@ run_agent_sandbox() {
864857

865858
log "Launching $AGENT_DISPLAY_NAME sandbox '$SANDBOX_NAME' on gateway '$GATEWAY'."
866859
run_agent_sandbox
860+
861+
# Scope manifest settings to this sandbox so launches never change gateway-wide
862+
# behavior for other users. The supervisor picks them up on its settings poll.
863+
# A failure leaves the gateway default (manual proposal approval) in effect, so
864+
# warn instead of tearing down the running sandbox.
865+
if ((SETTING_COUNT > 0)); then
866+
log "Configuring sandbox settings."
867+
fi
868+
for ((setting_index = 0; setting_index < SETTING_COUNT; setting_index++)); do
869+
key_var="SETTING_${setting_index}_KEY"
870+
value_var="SETTING_${setting_index}_VALUE"
871+
if ! openshell_cmd settings set "$SANDBOX_NAME" --key "${!key_var}" --value "${!value_var}" >/dev/null; then
872+
log "warning: could not set '${!key_var}' on sandbox '$SANDBOX_NAME'; if the gateway manages it globally, the global value applies."
873+
fi
874+
done

0 commit comments

Comments
 (0)