Skip to content

feat(agents): configure per-agent GitHub identities - #125199

Merged
steipete merged 17 commits into
mainfrom
steipete/managed-github-identities
Aug 17, 2026
Merged

steipete merged 17 commits into
mainfrom
steipete/managed-github-identities

Conversation

@steipete

@steipete steipete commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #125157

What Problem This Solves

Local agents on a shared Gateway could not inspect or deliberately select their effective GitHub CLI account. Operators had to mutate shared gh auth state or inject bearer environment variables, so repository actions could use the wrong account or fail with a scope-related 403 even when the intended account had repository access.

Why This Change Was Made

This adds a GitHub identity card under Agents → Tools. With no configuration, it reports and preserves the Gateway runtime user's native gh identity, including normal environment-token precedence and Git author. Operators can configure a managed system identity or a complete per-agent override, verify the account, and return to inherited/native behavior.

Managed profiles use one-use secret handoffs, immutable private profile generations, lifecycle-owned expiry and startup cleanup, serialized Control UI configuration mutation, and a host-selected environment projected consistently into local OpenClaw and Codex start/resume/warm/supervision paths. The Gateway preview credential added by #125158 remains a separate service owner; an explicit preview SecretRef is removed from agent execution by its exact name.

The boundary is intentionally narrow: this selects the local gh CLI/API identity and optional Git author. It does not claim generic Git transport isolation, forward credentials to cloud workers, or publish reconciled cloud branches. Gateway-owned publication is the next change in #125157.

User Impact

Operators can inspect the account an agent will actually use, set a shared default, and override individual agents without switching global gh state. Tokens are pasted once, never returned to the browser, expire autonomously if abandoned, and managed profile generations retire on Gateway restart.

Unconfigured installations preserve existing native GitHub authentication. Managed identities fail closed when their private profile is unavailable instead of silently falling back to another account. Processes with unrestricted host execution under the same OS account are not adversarially isolated; deployments needing that separation should use sandboxing or dedicated hosts/users.

Evidence

Exact reviewed head: 95be5176ef8774cfebd09bfae7faa7b91ee97950

  • Exact-head CI green: https://github.com/openclaw/openclaw/actions/runs/32074210532
  • Focused owner-boundary coverage across native/managed identity selection, one-use handoffs and autonomous expiry, profile cleanup, local exec, Codex start/resume/warm/supervision, protocol schemas, Swift generation, and Control UI behavior
  • Real RuntimeConfig coordinator regression proves a pending dirty autosave flushes before managed/inherit identity mutation and the authoritative refresh retains both changes
  • Generated Swift ToolsGitHubConfigureParams supports managed/inherit branches and round-trips all four system/agent combinations; Swift/Kotlin generation and native checks passed
  • Canonical eight-config Codex sweep passed 3,783/3,783 tests
  • Full changed-file gates passed across core, UI, extension, app, docs, formatting/lint/type graphs, config/protocol guards, prompt snapshots, Swift lint, and macOS packaging/install tests
  • Environment budget remains 501/501; runtime import-cycle and database-first guards passed
  • Remote trusted-source typecheck proof: https://crabbox.openclaw.ai/portal/runs/run_e0d8f5ed2f40
  • Final whole-branch P1 autoreview: clean
  • Latest ClawSweeper review: no actionable findings; proof sufficient and ready for maintainer review
  • Exact-head live proof: an existing credential was passed only on stdin to create a disposable isolated managed profile; /user verified the selected account, status reported system-configured / available, child preparation blanked ambient GitHub token precedence, profile and hosts.yml modes were 0700 / 0600, and the temporary state was deleted

The pinned Codex 0.147.0 contract was inspected directly at be6e8eac029b183056b7e4402879f15d2c85f61b:

Judged change split: production +1,962/-45; tests/test support +2,234/-10; generated +136/-3; docs +46/-3. Production growth establishes the new credential owner, Gateway API/config boundary, local execution projection, cleanup lifecycle, and operator UI.

Visual proof

Before — Agents → Tools has no GitHub identity owner:

Before: no GitHub identity configuration

After — the effective native account is visible and operators can configure a managed system or per-agent identity:

After: managed GitHub CLI identity settings

AI-assisted implementation; the Codex environment contract was verified directly against the pinned sibling Codex source.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling extensions: codex size: XL maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete
steipete force-pushed the steipete/managed-github-identities branch from 4241708 to 720005a Compare August 17, 2026 09:52
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 17, 2026
@steipete steipete self-assigned this Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 10:01
@steipete
steipete requested a review from a team as a code owner August 17, 2026 10:01
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 6:27 PM ET / 22:27 UTC.

ClawSweeper review

What this changes

Adds Gateway-managed system and per-agent GitHub CLI identities, Control UI configuration, one-use credential setup, and local tool/Codex environment projection while preserving native credentials by default.

Merge readiness

⚠️ Needs maintainer review before merge - 4 items remain

Keep open for maintainer review: the latest head addresses the prior ambient-authentication concern and no definite line-level defect was found, but this is a security-sensitive core identity foundation whose Codex app-server contract could not be directly inspected in this environment.

Priority: P2
Reviewed head: 95be5176ef8774cfebd09bfae7faa7b91ee97950
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has broad boundary coverage and reported live evidence, but its core ownership and upstream Codex contract remain unresolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied PR context reports exact-head live GitHub credential behavior in addition to boundary tests; direct Codex-contract inspection remains a reviewer-side maintainer gate, not a contributor-proof failure.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied PR context reports exact-head live GitHub credential behavior in addition to boundary tests; direct Codex-contract inspection remains a reviewer-side maintainer gate, not a contributor-proof failure.
Evidence reviewed 9 items Managed identity projection: The identity owner builds either a managed profile overlay or native environment and removes preview-service credentials from tool execution.
Native authentication preservation: Local Gateway execution restores ambient GH_TOKEN/GITHUB_TOKEN only when no managed local identity applies, addressing the previous review finding without reintroducing managed-profile leakage.
Codex execution boundary: The Codex connection projects local identity only for local execution, scrubs credentials for remote execution, and selects login-shell behavior from the prepared host facts.
Findings None None.
Security None None.

How this fits together

The Control UI configures an agent identity through Gateway methods, which create a protected local GitHub CLI profile and pass only the applicable environment to local agent tools. Remote execution receives credential scrubbing rather than the managed identity, while local Codex runs receive the host-selected identity settings.

flowchart LR
A[Operator in Agents Tools] --> B[Gateway identity setup]
B --> C[One-use secret handoff]
C --> D[Managed GitHub CLI profile]
C --> E[Agent identity configuration]
E --> F[Local tool environment]
E --> G[Local Codex harness]
F --> H[GitHub CLI and Git author]
G --> H
Loading

Decision needed

Question Recommendation
Should OpenClaw own this staged system and per-agent local GitHub identity foundation before the separate cloud-publication phase? Sponsor the scoped local foundation: Keep native credentials as the default, approve the managed local identity boundary after contract and upgrade proof, and leave cloud publication to the linked later phase.

Why: The change adds persistent core configuration, Gateway protocol methods, protected credential-profile lifecycle, and altered local execution semantics; this ownership boundary needs maintainer intent beyond a mechanical code review.

Before merge

  • Resolve merge risk (P1) - A managed identity intentionally fails closed when its protected profile is unavailable; fresh-install and upgrade recovery must be demonstrated so existing operators are not stranded without an actionable path.
  • Resolve merge risk (P1) - The PR changes Codex app-server environment and login-shell policy, but the required @openai/codex 0.147.0 source/runtime contract could not be directly inspected because the mandated sibling checkout is unavailable.
  • Complete next step (P2) - Manual review is required for core product ownership and the unverified upstream Codex runtime contract, not a mechanical repair.
Agent review details

Security

None.

PR surface

Source +1926, Tests +2169, Docs +43, Generated +6, Other +173. Total +4317 across 74 files.

View PR surface stats
Area Files Added Removed Net
Source 46 1971 45 +1926
Tests 19 2178 9 +2169
Docs 3 46 3 +43
Config 0 0 0 0
Generated 3 9 3 +6
Other 3 174 1 +173
Total 74 4378 61 +4317

Review metrics

Metric Value Why it matters
Configuration and protocol surface 2 configuration scopes, 2 Gateway methods System and per-agent settings plus new operator-scoped methods are compatibility- and operations-sensitive.
Production versus test LOC Judged split unavailable; supplied PR context reports +4,378 / -61 total The local grafted snapshot has no merge base, so an independent production/test delta cannot be computed from a valid PR diff.

Stored data model

Persistent data-model change detected: serialized state: extensions/codex/src/app-server/run-attempt.native-hook-relay.test.ts, serialized state: src/agents/github-tool-profile-cleanup.test.ts, serialized state: ui/src/pages/agents/github-identity-controller.ts, unknown-data-model-change: packages/gateway-protocol/src/schema/agents-models-skills.ts, unknown-data-model-change: packages/gateway-protocol/src/schema/tools-github.test.ts, unknown-data-model-change: src/config/schema.help.runtime.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #125157
Summary: This PR implements the linked issue's local managed-identity stage, while its proposed Gateway-owned cloud publication stage remains separate.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Validate contract and upgrade behavior before merge (recommended)
    Inspect the exact Codex 0.147 app-server contract and record fresh-install plus existing-native-auth recovery evidence before approving this persistent identity path.
  2. Pause if core ownership is not sponsored
    Close or defer the PR if maintainers prefer a plugin-owned GitHub identity seam rather than Gateway-managed identities.

Technical review

Best possible solution:

Keep native credentials as the default and land the isolated local-profile design only after maintainer sponsorship, direct Codex 0.147 contract inspection, and fresh-plus-upgrade behavior evidence; keep cloud publication in the linked follow-up.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction: this is a new feature PR; source and focused tests cover native and managed paths, but the read-only grafted checkout cannot establish an independently runnable current-main flow.

Is this the best way to solve the issue?

Unclear pending maintainer intent: separating managed identities from shared gh auth is the sounder design, but core ownership and the exact Codex runtime contract still need confirmation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against aebe360349ae.

Labels

Label justifications:

  • P2: This is a substantial but opt-in identity-management feature with bounded operator impact rather than an established default-path regression.
  • merge-risk: 🚨 compatibility: New persistent system and per-agent identity configuration can affect existing native GitHub authentication and recovery behavior.
  • merge-risk: 🚨 security-boundary: The PR creates and projects protected GitHub credentials across Gateway, local tools, and Codex execution boundaries.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied PR context reports exact-head live GitHub credential behavior in addition to boundary tests; direct Codex-contract inspection remains a reviewer-side maintainer gate, not a contributor-proof failure.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied PR context reports exact-head live GitHub credential behavior in addition to boundary tests; direct Codex-contract inspection remains a reviewer-side maintainer gate, not a contributor-proof failure.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the current PR head and the linked staged GitHub-identity work, including the merged adjacent Gateway credential separation. (role: feature owner and recent area contributor; confidence: medium; commits: 95be5176ef87, 1487b45eb810; files: src/agents/github-tool-identity.ts, src/gateway/server-methods/tools-github.ts, extensions/codex/src/app-server/run-attempt-connection.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record direct verification against the pinned Codex 0.147.0 app-server contract.
  • Record fresh-install and upgrade recovery behavior for native and managed identities.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-17T14:02:26.100Z sha fe61c11 :: found issues before merge. :: [P2] Expire abandoned setup handoffs without later secret activity
  • reviewed 2026-08-17T14:17:53.021Z sha fe61c11 :: found issues before merge. :: [P2] Delete abandoned setup handoffs at their expiry
  • reviewed 2026-08-17T15:31:13.770Z sha cb9294c :: found issues before merge. :: [P2] Schedule expiry of abandoned setup handoffs | [P2] Reject blank Git author fields before consuming the handoff
  • reviewed 2026-08-17T17:32:49.950Z sha 16afe02 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T18:26:53.417Z sha a5fed6b :: found issues before merge. :: [P1] Serialize identity mutations with configuration autosave | [P2] Emit a usable Swift model for the configure RPC
  • reviewed 2026-08-17T19:24:40.270Z sha 911cb12 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T20:15:50.830Z sha 063676c :: found issues before merge. :: [P1] Preserve ambient GitHub authentication until operators opt in
  • reviewed 2026-08-17T20:28:40.412Z sha 34dee10 :: found issues before merge. :: [P1] Preserve ambient GitHub authentication until operators opt in

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 17, 2026
@wintermute-texture

Copy link
Copy Markdown

Nudge: This PR has been awaiting review for over 3 hours.

@steipete
steipete force-pushed the steipete/managed-github-identities branch from ee2097d to 08a66d9 Compare August 17, 2026 12:00
@clawsweeper clawsweeper Bot removed the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Aug 17, 2026
@steipete
steipete force-pushed the steipete/managed-github-identities branch from 9ac273a to fe61c11 Compare August 17, 2026 13:47
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 17, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready at exact reviewed head 95be5176ef8774cfebd09bfae7faa7b91ee97950.

  • Exact-head CI is green: run 32074210532, including the final openclaw/ci-gate. Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 125199 passed at the unchanged head in hosted_exact_or_recent_parent mode and reused that exact-head hosted run; no separate tbx_ lease or remote-run URL was created.
  • Direct pinned Codex rust-v0.147.0 evidence confirms login-shell selection, environment override order, and experimental_use_profile serialization at commit be6e8eac029b183056b7e4402879f15d2c85f61b.
  • Disposable-profile live proof verified /user, system-configured / available, managed GH_CONFIG_DIR projection, profile/hosts modes 0700 / 0600, and cleanup. The credential traveled only over stdin and was not logged.
  • Generated Swift ToolsGitHubConfigureParams round trips all system/agent managed/inherit combinations. The real UI RuntimeConfigCapability coordinator proof verifies serialized mutation, pending autosave flush, and mutation-owned authoritative refresh.
  • Judged split: production +1,962/-45; tests/test support +2,234/-10; generated +136/-3; docs +46/-3. Visual before/after evidence is embedded in the PR body.
  • The latest exact-head ClawSweeper review has no findings. Its optional rank-up moves are satisfied by the direct pinned Codex inspection and fresh-install/upgrade recovery coverage for native and managed identities.

No known proof gap remains for the local managed/native identity contract. Cloud publication remains the separate phase tracked in #125157.

@steipete
steipete merged commit 6e458d8 into main Aug 17, 2026
242 checks passed
@steipete
steipete deleted the steipete/managed-github-identities branch August 17, 2026 22:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Aug 18, 2026
…es (#125472)

The panel from #125199 rendered raw wire enums in code tags, used
form-grid/field markup whose styles the agents page never loads (bare
unstyled inputs outside the card), referenced non-existent avatar
classes, and put callouts inside the settings group. Rebuild it on the
canonical settings primitives: status rows with dot status and friendly
source/evidence labels, a System/This Agent segmented scope control,
the settings secret input (gains a disabled prop), a danger status row
for errors, and a quiet-inherit + primary-save action row. Retitle to
"GitHub Identity" and move it below Tool Access and Available Right
Now. Add a .settings-account primitive for the 20px round avatar.

Live-tested on an isolated dev gateway: native-credential verify via
the GitHub API, segmented scope switching, and the empty-token error
row. Controller behavior unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
* feat(agents): add managed GitHub identities

* fix(agents): use opaque GitHub setup handles

* style(codex): format managed shell environment call

* refactor(agents): own managed GitHub process identity

* chore(config): refresh baseline after rebase

* fix(ci): satisfy managed GitHub identity gates

* fix(ci): repair managed GitHub identity checks

* test(agents): align GitHub identity CI coverage

* fix(codex): scope login shell isolation

* fix(agents): let managed gh profiles authenticate

* fix(agents): harden GitHub identity setup

* test(gateway): align method suffix counts

* fix(ui): serialize GitHub identity mutations

* fix(protocol): generate GitHub configure requests

* test(ui): restore timers after identity tests

* fix(ui): preserve GitHub identity mutation ownership

* fix(agents): preserve native GitHub CLI auth
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
…es (openclaw#125472)

The panel from openclaw#125199 rendered raw wire enums in code tags, used
form-grid/field markup whose styles the agents page never loads (bare
unstyled inputs outside the card), referenced non-existent avatar
classes, and put callouts inside the settings group. Rebuild it on the
canonical settings primitives: status rows with dot status and friendly
source/evidence labels, a System/This Agent segmented scope control,
the settings secret input (gains a disabled prop), a danger status row
for errors, and a quiet-inherit + primary-save action row. Retitle to
"GitHub Identity" and move it below Tool Access and Available Right
Now. Add a .settings-account primitive for the 20px round avatar.

Live-tested on an isolated dev gateway: native-credential verify via
the GitHub API, segmented scope switching, and the empty-token error
row. Controller behavior unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: web-ui App: web-ui docs Improvements or additions to documentation extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants