Skip to content

fix(humanize2): pass agentDefaults to AgentRunCoordinator and support per-agent permission/sandbox/extraArgs#166

Merged
SihaoLiu merged 4 commits into
PolyArch:h2-devfrom
zevorn:fix/agent-defaults-permission-bypass
May 17, 2026
Merged

fix(humanize2): pass agentDefaults to AgentRunCoordinator and support per-agent permission/sandbox/extraArgs#166
SihaoLiu merged 4 commits into
PolyArch:h2-devfrom
zevorn:fix/agent-defaults-permission-bypass

Conversation

@zevorn
Copy link
Copy Markdown
Contributor

@zevorn zevorn commented May 17, 2026

Summary

Two fixes for humanize2 workflow agent launches that were blocking gen-idea and other workflows from completing successfully.

Bug 1: agentDefaults not passed to AgentRunCoordinator

Root cause: AgentRunCoordinator was constructed without agentDefaults in hub-server.ts. The config was loaded and passed to createHubHttpServer, but the AgentRunCoordinator (which actually creates and executes agent runs) never received it. This meant permissionMode, sandbox, and extraArgs from ~/.h2/config.yaml were silently ignored.

Impact:

  • Claude agents ran with permissionMode: default, blocking MCP tool calls (artifact_deliver, artifact_get) that require user approval in headless claude -p mode
  • Codex agents failed with "Not inside a trusted directory" when the working directory is not a git repo

Feature: Extended agent config surface

AgentModelDefaults now supports three new per-agent fields:

Field Type Purpose
permissionMode PermissionMode Claude CLI --permission-mode (e.g., bypassPermissions)
sandbox SandboxMode Codex CLI --sandbox
extraArgs string[] Arbitrary extra CLI args (e.g., --skip-git-repo-check, --dangerously-bypass-approvals-and-sandbox)

YAML parser supports both inline comma-separated values and multi-line list items for extraArgs.

Configuration example

agents:
  claude:
    model: claude-opus-4-7
    reasoningEffort: xhigh
    permissionMode: bypassPermissions
  codex:
    model: gpt-5.5
    reasoningEffort: xhigh
    extraArgs:
      - --dangerously-bypass-approvals-and-sandbox
      - --skip-git-repo-check

Changes

File Change
src/config.ts Extended AgentModelDefaults interface + YAML parser
src/hub/runs.ts Applied permissionMode/sandbox/extraArgs from config defaults in createRun
src/hub-server.ts Passed agentDefaults to AgentRunCoordinator constructor (critical bugfix)

Verification

Tested with gen-idea workflow:

  • Before: 3/3 Codex explorers failed, Claude explorers needed per-tool permission allowlisting
  • After: All 6 explorers completed successfully, idea-draft delivered correctly

Closes #165

… per-agent permission/sandbox/extraArgs

Two fixes for humanize2 workflow agent launches:

1. **Critical bug**: `AgentRunCoordinator` was constructed without `agentDefaults`,
   so `permissionMode`, `sandbox`, and `extraArgs` from `~/.h2/config.yaml` were
   silently ignored for all workflow-spawned agents. This caused:
   - Claude agents to run with default permission mode, blocking MCP tool calls
     (artifact_deliver, etc.) that require user approval in headless mode
   - Codex agents to fail with "Not inside a trusted directory" when the working
     directory is not a git repo

2. **Extended config surface**: `AgentModelDefaults` now supports `permissionMode`,
   `sandbox`, and `extraArgs` per agent. The YAML parser handles both inline
   comma-separated values and multi-line list items for extraArgs.

With this fix, users can configure in `~/.h2/config.yaml`:
  agents:
    claude:
      permissionMode: bypassPermissions
    codex:
      extraArgs:
        - --dangerously-bypass-approvals-and-sandbox
        - --skip-git-repo-check

Closes PolyArch#165
Copy link
Copy Markdown

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

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: b95c3691ef

ℹ️ 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 src/config.ts Outdated
@zevorn
Copy link
Copy Markdown
Contributor Author

zevorn commented May 17, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ 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".

…on state

Scope the YAML list-item handler to only consume lines inside an
agents.extraArgs block (similar to workflow.scripts.allow tracking),
preventing unrelated `- ` lines under agent stanzas from being
silently captured as CLI arguments.
Copy link
Copy Markdown

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

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: bd0d0e6dce

ℹ️ 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 src/config.ts
…fig parser

When the parser was in `agents.extraArgs` state (multiline list) and
encountered a new indent-2 agent header, it updated currentAgent but left
section unchanged. Subsequent model/reasoningEffort/permissionMode/sandbox
fields for that agent were silently ignored because their handler requires
section === "agents".
@zevorn
Copy link
Copy Markdown
Contributor Author

zevorn commented May 17, 2026

@codex review again

Copy link
Copy Markdown

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

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: 557a19cb3f

ℹ️ 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 src/config.ts
…elds

When extraArgs: [] switched section to "agents.extraArgs", subsequent
sibling fields (model, reasoningEffort, permissionMode, sandbox) under
the same agent were silently ignored because section was never reverted.
Now reset section back to "agents" when a non-list-item line is
encountered at indent >= 4.
@zevorn
Copy link
Copy Markdown
Contributor Author

zevorn commented May 17, 2026

@codex review again

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ 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".

@zevorn zevorn requested a review from SihaoLiu May 17, 2026 13:28
@SihaoLiu SihaoLiu merged commit e896c9b into PolyArch:h2-dev May 17, 2026
3 checks passed
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