Skip to content

feat(runtime): isolate local agent homes with API credentials - #414

Merged
zpzjzj merged 15 commits into
alibaba:mainfrom
karanb192:feat/isolate-local-agent-home
Nov 23, 2026
Merged

zpzjzj merged 15 commits into
alibaba:mainfrom
karanb192:feat/isolate-local-agent-home

Conversation

@karanb192

@karanb192 karanb192 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add environment.agent_home: temporary for local Claude Code and Codex evals with API credentials, as an initial implementation of #404. Each case, benchmark arm and retry gets a separate agent home. The default inherited mode preserves inherited home settings.

Changes

  • Put every automatic local workspace at <system temp>/skill-up-*/workspace/, so switching home modes leaves the workspace layout and the meaning of .. unchanged. An explicit --workspace stays at the supplied path; temporary gives it a separate temporary home.
  • In temporary mode, point HOME, USERPROFILE and CODEX_HOME at the run directory. Redirect Claude, XDG and Windows application-data paths underneath it, after command environment overrides. Disable BASH_ENV and ENV; preserve executable lookup and other inherited variables. Codex authentication and sessions stay outside workspace artifacts and diffs, while transcript collection follows $CODEX_HOME/sessions.
  • Check run and judge engines and API credentials before setup. Claude Code accepts ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN; Codex accepts OPENAI_API_KEY. Normal credential configuration can supply these. Probes use non-secret presence markers, and Codex initializes API-key login through stdin before each invocation.
  • Clean up the entire temporary run directory in both modes, preserving explicit workspaces. --no-delete retains the tree. Clean up a script judge's runtime when workspace creation fails. Add config defaults, validation, regression tests, and update the CLI help, guides, package docs and bundled Skill reference.
  • Run both home modes in every existing Codex compatibility job: 0.80.0 with Chat Completions and Responses, and 0.169.0 with Responses. The temporary-mode case checks runtime home redirection, API-key login, fresh and resumed turns, and collection of each turn's session JSONL from the temporary home. It checks that the inherited home is untouched; inherited mode must not create an API-key login. Increase the job limit from 10 to 20 minutes and each test-process limit from 300 to 600 seconds to allow both modes per row.

Temporary mode requires the none runtime and supported run/judge engines. Personal login files and OS-keychain credentials are not copied. A retained home can contain the Codex API key. Workspace instructions, system configuration and other inherited environment variables remain available; this option is not a filesystem security boundary.

Test plan

  • make verify with Go 1.26.10
  • Go race suite (make -o test-plugin test)
  • Quick make e2e and npm run docs:build
  • Regression tests for default and explicit home modes, config validation, consistent workspace layout, cleanup and preservation, environment handling, credential probes, and Codex session collection
  • Both home modes against real Codex 0.169.0 and 0.170.0 with the local mock Responses provider
  • Negative control: disabling API-key login makes the temporary-mode test fail because its auth file is absent
  • Negative control: unconditional API-key login makes the inherited-mode test fail

Codex 0.80.0 did not start within the local version-check timeout; its two Linux CI jobs must verify that version on this head. Plugin/skill regression scripts and live provider calls remain deferred.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T06:42:36.891242Z 70f4ec9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70f4ec99a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/agent/isolated_home.go Resolved

zpzjzj commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Could we use the temporary directory as CODEX_HOME and put the case workspace in a workspace/ subdirectory? For example, CODEX_HOME=/tmp/skill-up-home-456 and cwd=/tmp/skill-up-home-456/workspace.

That would give Codex a fresh state directory while keeping auth.json and sessions/ outside the workspace artifact and diff scope. The existing session collector already follows $CODEX_HOME/sessions, and runtime cleanup could remove the whole temporary tree. For an explicit --workspace, we could keep the user’s directory in place and give that runtime a separate temporary home.

zpzjzj commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Sorry, I overlooked how my earlier suggestion would change the workspace layout when the option is toggled. Could we use the same layout for every automatically created workspace, $TMPDIR/skill-up-*/workspace/, with a temporary run directory as its parent?

I'd suggest environment.agent_home with two values: inherited (the default), which keeps the inherited home settings, and temporary, which redirects HOME, CODEX_HOME, and the related variables into the temporary run directory. That way, switching the mode leaves the workspace layout and the meaning of .. unchanged. An explicit --workspace would stay at the user-provided path in both modes, with a separate temporary home in temporary mode.

zpzjzj commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

The workspace layout concern is resolved in 392d4a0. Both home modes now use the same layout for automatically created workspaces, and an explicit --workspace stays at the supplied path.

Could we add an agent_home: temporary case to the existing Codex compatibility matrix? The current test sets HOME and CODEX_HOME itself and uses the default inherited mode, so the passing 0.80.0 and 0.169.0 jobs do not exercise the new runtime redirection or the API-key login it triggers. The existing local mock provider should be enough to verify login, a fresh turn, resume, and collection of the session JSONL from the temporary home.

@zpzjzj zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zpzjzj
zpzjzj added this pull request to the merge queue Nov 23, 2026
Merged via the queue into alibaba:main with commit a4af3f2 Nov 23, 2026
24 checks passed
BiBoyang added a commit to BiBoyang/skill-up that referenced this pull request Nov 23, 2026
Bring in alibaba#429, alibaba#414 and alibaba#424 from main. The only textual conflict was in
CHANGELOG.md, where this branch and alibaba#414 each added an entry at the top of
Unreleased / Added; both entries are kept.
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