Skip to content

fix(agent): expose built-in origin to clients - #59656

Open
kill74 wants to merge 1 commit into
anomalyco:devfrom
kill74:agent-origin
Open

kill74 wants to merge 1 commit into
anomalyco:devfrom
kill74:agent-origin

Conversation

@kill74

@kill74 kill74 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #50269

Related: #57812, #59642

Type of change

  • Bug fix

What does this PR do?

Restores the built-in/custom agent distinction on the public agent API.

V1 carried native on every agent: true for built-in agents and false for agents defined in config. V2 dropped the field from the public Agent.Info, so the app's hasCustomAgent() check (native === false) always returned false. A custom primary agent therefore never auto-revealed the composer agent picker, and users with the default "Show agent" setting had no way to select it.

  • packages/schema/src/agent.ts: add optional native to Agent.Info.
  • packages/core/src/plugin/agent.ts and packages/core/src/plugin/plan.ts: mark all built-in agents as native = true.
  • packages/core/src/config/plugin/agent.ts: mark newly created config agents as native = false. Overrides of a built-in agent keep the built-in value, matching V1.
  • packages/app/src/runtime/server/global-sync/utils.ts: forward native through normalizeAgentList, which previously dropped it.
  • packages/client/src/promise/generated/types.ts: regenerated from the schema.

The hidden-by-default product behavior is unchanged: the picker still requires Settings → General → Show agent, but it now appears automatically when a custom primary agent exists, as it did before V2.

How did you verify your code works?

  • packages/core: bun test test/config/agent.test.ts test/plugin/plan.test.ts — 51 pass / 0 fail. The new cases assert a built-in override stays native: true, a config-defined agent is native: false, and the Plan agent is native: true.
  • packages/app: bun test --conditions=solid --isolate --preload ../ui/test/solid-jsx.ts --preload ./happydom.ts src/runtime/server/global-sync/utils.test.ts src/providers/models/agent.test.ts — 14 pass / 0 fail. The adapter case now asserts native reaches the UI model.
  • packages/schema: bun test — 89 pass / 0 fail.
  • Turbo typecheck: 32/35 packages pass. The other three (www, posts, patchmark) fail only on this Windows machine because Device Guard blocks their freshly installed astro/tsc shims; running them through bunx passes (astro check 0 errors in both Astro packages, tsc --noEmit 0 errors in patchmark).
  • Lint: oxlint reports 0 errors, the ast-grep scan passes, and the SDK docs check reports 0 problems.

No manual desktop/web QA was performed; the verification above covers each propagation step from the agent service through the generated client types to the app adapter.

Visual

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 72" width="240" height="72" role="img" aria-label="A custom agent appears in the composer">
  <title>A custom agent appears in the composer</title>
  <style>
    .picker { opacity: 0; animation: picker 3s ease-in-out infinite; }
    .caret { animation: caret 1.2s steps(2) infinite; }
    @keyframes picker {
      0%, 18% { opacity: 0; transform: translate(4px, 2px); }
      32%, 82% { opacity: 1; transform: translate(0, 0); }
      96%, 100% { opacity: 0; transform: translate(4px, 2px); }
    }
    @keyframes caret {
      0%, 49% { opacity: 1; }
      50%, 100% { opacity: 0.35; }
    }
    @media (prefers-reduced-motion: reduce) {
      .picker { opacity: 1; animation: none; transform: none; }
      .caret { animation: none; }
    }
  </style>
  <rect x="8.5" y="14.5" width="223" height="43" rx="9" fill="none" stroke="currentColor" stroke-opacity="0.28"/>
  <rect x="20" y="26" width="88" height="5" rx="2.5" fill="currentColor" fill-opacity="0.28"/>
  <rect x="20" y="37" width="58" height="5" rx="2.5" fill="currentColor" fill-opacity="0.18"/>
  <g transform="translate(150 33)">
    <rect width="68" height="18" rx="6" fill="currentColor" fill-opacity="0.07" stroke="currentColor" stroke-opacity="0.22"/>
    <text x="8" y="12.5" font-family="ui-sans-serif, system-ui, sans-serif" font-size="8" fill="currentColor" fill-opacity="0.75">gpt-5</text>
  </g>
  <g transform="translate(96 33)">
    <g class="picker">
      <rect width="48" height="18" rx="6" fill="currentColor" fill-opacity="0.12" stroke="currentColor" stroke-opacity="0.45"/>
      <text x="7" y="12.5" font-family="ui-sans-serif, system-ui, sans-serif" font-size="8" fill="currentColor">reviewer</text>
      <path class="caret" d="M37 7.5l2.5 2.5 2.5-2.5" fill="none" stroke="currentColor" stroke-opacity="0.7" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
    </g>
  </g>
</svg>

Screenshots / recordings

Not applicable: schema field, core agent flags, and client type propagation. No visual changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #57812, #59642, #48810

Public API: adds optional native to Agent.Info, returned by GET /api/agent and in the client AgentInfo type (backwards compatible)

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. contributor and removed needs:compliance This means the issue will auto-close after 2 hours. labels Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix works. I ran serve from source on the base and on this branch, with a project-local primary agent in .opencode/agents/reviewer.md, and called GET /api/agent. On the base, no agent carries native. With this PR, the built-in agents return native: true and reviewer returns native: false. While the server was running I added a second agent file and a config entry overriding build. After the automatic reload, the new agent was native: false and the overridden build stayed native: true. The core and app tests that cover this pass, and tsc is clean for schema, core, app and client. I didn't drive the web or desktop composer itself; the step from the agent list to the picker is covered by the app's unit tests.

Public API: one addition, an optional native: boolean on Agent.Info, so GET /api/agent and GET /api/agent/:id responses and the generated client AgentInfo type gain it. This is backwards compatible: nothing is removed or renamed, and existing clients can ignore the field.

One point that doesn't block this: agents added through a plugin's agent.transform leave native unset. The app only treats native === false as custom, so a primary agent added by a plugin still won't make the picker appear on its own, even though the schema comment groups plugins with config. If plugin agents should count as custom, they need native = false too. Otherwise the comment could say they are left unset.

Related: #57812, #59642, #48810

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new push rebases the same commit onto a newer dev; the change itself is identical. I checked it again on the new head. GET /api/agent from a source serve returns native: true for the built-in agents and native: false for a project-local primary agent, the core and app tests that cover this pass, and tsc is clean for schema and core.

Public API: unchanged since the last review. The only addition is an optional native on Agent.Info, in the /api/agent responses and the client AgentInfo type. It is backwards compatible.

Nothing new to raise.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

app: project-local custom agents never make the composer agent picker visible (native flag missing from public Agent.Info)

1 participant