Skip to content

feat(agent-adapter): advertise approval tiers before session start - #305

Merged
lucas77778 merged 4 commits into
masterfrom
xuan/code-463
Jul 29, 2026
Merged

feat(agent-adapter): advertise approval tiers before session start#305
lucas77778 merged 4 commits into
masterfrom
xuan/code-463

Conversation

@AprilNEA

Copy link
Copy Markdown
Member

Closes CODE-463.

The gap

The pre-session agent catalog landed in 38c6389f with the whole schema → engine → client → UI chain, but only pi ever overrode startCatalog. claude-code, opencode and grok-build inherited the base default, and codex (which gained a catalog later, for the effort work) returned a hardcoded policies: []:

startCatalog(_opts?: AgentStartCatalogOptions): Promise<AgentStartCatalog> {
  return Promise.resolve({ models: [], policies: [] });
}

new-session-surface.tsx gates the approval-policy control on catalog && catalog.policies.length > 0, so approvalPolicy resolved to undefined and the New Task surface rendered no picker for four of the five agents. In-session reflection was never affected — claude-code still advertises availablePolicies once a session starts — which is why this reads as "the picker disappeared on New Task" rather than "the feature is gone".

What this does

Fills in the missing half, so every adapter advertises the tiers a session would actually run under, and honors a pick made before the session exists.

agent pre-session policies initial pick
claude-code the five tiers + the resolved permissions.defaultMode as defaultPolicyId outranks the settings default; unknown id degrades to it with an error event
codex the three tiers + acceptEdits counts as an explicit pick, so it may override a config.toml sandbox from the first turn, exactly like a live switch; unknown id degrades to acceptEdits
opencode selectable agents (the agent axis) + models, both directory-scoped, read over the shared history server outranks a resumed session's recorded agent; an unselectable pick degrades to the catalog default with an error
grok-build the fixed bypassPermissions tier n/a (visibility only — set-approval-policy still rejects)
pi already shipped already shipped

opencode's selectable-agent and reachable-model mapping moved to two module-level pure functions so the live onStart fetches and the pre-session read share one definition instead of drifting.

A failed pre-session read degrades to an empty axis rather than blocking session creation, matching the live best-effort catalog fetches.

Notes

  • grok-build is beyond the original scope (it postdates the work this restores), but leaving it out would have shown the picker for four of five agents.
  • No wire change — AgentStartCatalogSchema already carries policies/defaultPolicyId, and the engine forwards the catalog verbatim.

Verification

pnpm check:ci and pnpm test both pass (2011 passed / 5 skipped). New coverage: pre-session catalog contents per adapter, the initial-pick path, and the degrade-with-error path; codex additionally asserts that a new-session pick overrides a configured sandbox while an unknown one does not.

Not yet driven in the running app — the adapter contract is covered by tests, and the engine/client legs of the chain were already live for pi.

@linear-code

linear-code Bot commented Jul 29, 2026

Copy link
Copy Markdown

CODE-463

@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: 5f436c454a

ℹ️ 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 packages/host/agent-adapter/src/native/codex/adapter.ts
Comment thread packages/host/agent-adapter/src/native/claude-code.ts
@lucas77778
lucas77778 self-requested a review July 29, 2026 12:49
@lucas77778
lucas77778 merged commit d9b74b0 into master Jul 29, 2026
8 of 10 checks passed
@lucas77778
lucas77778 deleted the xuan/code-463 branch July 29, 2026 12:49
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