Repository navigation
fix(skills): make env_passthrough registrations visible across tool context snapshots - #90011
Open
liuhao1024 wants to merge 1 commit into
Open
liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
Author
|
The failing checks here are a pre-existing main regression, not caused by this diff: the failing test is the FAL catalog all-off upscale invariant ( Main has since resolved it on its own (the catalog entry was fixed and the invariant test was dropped in 00888e8), so this failure should disappear on the next rebase. This PR's changes don't touch the image-generation catalog or its tests. Not re-running CI since the failing slice is unrelated to the change under review. |
…ontext snapshots skill_view registers a skill's declared env vars (required_environment_ variables and the legacy prerequisites.env_vars) into the sandbox passthrough allowlist. The allowlist was backed by a ContextVar, and tool dispatch fans each tool call onto a worker whose context is a copy_context() snapshot taken at submit time (tools.thread_context.propagate_context_to_thread). The registration therefore lived and died inside the skill_view worker's snapshot: the submitting thread's context never saw it, and the next tool's snapshot (execute_code, terminal) always started from an empty allowlist — so a skill's env vars were never passed through, on any turn, in any session (NousResearch#90004). The config-based allowlist (terminal.env_passthrough) is a module-level global and worked, which is why manually adding the var there was the only workaround. Store the skill-registered names in a process-wide set, matching the config path's visibility. Cross-session exposure is limited to the names — values still resolve per profile through resolve_passthrough_value's secret_scope, so a name registered by one session cannot read another profile's secret. clear_env_passthrough keeps its reset semantics; a later skill_view re-registers on demand.
liuhao1024
force-pushed
the
liuhao/cron-bugfix-90004
branch
from
August 31, 2026 20:58
696a1a7 to
5e87201
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #90004: a skill's declared env vars (
required_environment_variablesand the legacyprerequisites.env_vars) never reachedexecute_code/terminal, on any turn or session — only manually adding the var toterminal.env_passthroughin config.yaml worked.Mechanism.
skill_viewregisters the skill's vars into the sandbox passthrough allowlist, which was backed by aContextVar. Tool dispatch fans each tool call onto a worker whose context is acopy_context()snapshot taken at submit time (tools.thread_context.propagate_context_to_thread). The registration therefore lived and died inside the skill_view worker's snapshot:ContextVar.setin a copied context cannot reach the parent), andSo the failure was deterministic, which matches the report exactly (consistent across fresh sessions; restart doesn't help). The config-based allowlist (
terminal.env_passthrough) is a module-level global — that visibility difference is precisely why the manual workaround worked. I reproduced the invisibility in isolation on unmodified main (register inside a copied context, then a sibling snapshot sees False).Fix. Store the skill-registered names in a process-wide set, matching the config path's visibility. Cross-session exposure is limited to the names: values still resolve per profile through
resolve_passthrough_value'ssecret_scope, so a name registered by one session cannot read another profile's secret.clear_env_passthroughkeeps its reset semantics; a laterskill_viewre-registers on demand.This un-breaks at least the 4 bundled skills the report lists as using the legacy key (
notion,airtable,gif-search,teams-meeting-pipeline) — and equally affects skills using the modernrequired_environment_variableskey, since both feed the same registration call.Related Issue
Fixes #90004
Type of Change
Changes Made
tools/env_passthrough.py: the skill-registration allowlist moves from a ContextVar-backed set to a process-wide module-level set (_get_allowedreturns it;register_env_passthroughmutates it in place;clear_env_passthroughclears it). The unused ContextVar import is dropped; comments document why process-wide visibility is required by the tool-dispatch snapshot model and what the exposure boundary is.How to Test
pytest tests/tools/test_env_passthrough.py -q— 25 passed (2 new tests).test_registration_in_copied_context_is_visible_to_sibling_snapshotruns the register-then-check sequence inside a pristine context (so the fixture's current-context initialization cannot mask the bug) — it fails on unmodified main and passes with the fix.tests/tools/test_skill_env_passthrough.py+tests/tools/test_local_env_blocklist.py: 104 passed, 2 skipped — the provider-credential blocklist (GHSA-rhgp-j443-p4rf) and profile-scope semantics are unchanged.tests/tools/test_code_execution*.py: 98 passed, 3 skipped; the single interrupt-handling failure reproduces identically on unmodified main (pre-existing, unrelated).Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A