Skip to content

fix(agents): carry the agent's model into the Cursor render (#830) - #856

Open
ydflow wants to merge 1 commit into
Tencent:mainfrom
ydflow:fix/cursor-agent-model
Open

ydflow wants to merge 1 commit into
Tencent:mainfrom
ydflow:fix/cursor-agent-model

Conversation

@ydflow

@ydflow ydflow commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Fixes the Cursor half of #830's open question "Cursor drops model when it renders agents today" as the separate change that note asks for. It does not touch alias resolution — the model[effort=...] form belongs to the alias proposal, still open there.

Problem

renderForCursor was the one renderer that dropped spec.model. Every other renderer writes the agent's declared model into its native file — Claude (frontmatterData['model']), the Codex TOML family, Copilot (json['model']) — and reverseFromCursor reads it back (COMMON_CURSOR_FIELDS whitelists model as a common field, not a tool extra). So the team repo can declare a model, every other tool receives it, and the Cursor copy silently runs on Cursor's default model.

Real CLI, sandbox HOME, team repo with one agent declaring model: claude-opus-4, teamai pull --force on main @ 84d8ba7:

# .cursor/agents/code-reviewer.md
---
agent_id: code-reviewer
description: Reviews code for the team
---
You are a careful code reviewer.

The model is gone. The asymmetry also runs the other way: a Cursor agent file that carries a model parses it back into the spec, so the render and the reverse disagree about the same field.

Fix

renderForCursor writes model verbatim when the spec declares one, exactly like the other renderers:

---
agent_id: code-reviewer
description: Reviews code for the team
model: claude-opus-4
---
You are a careful code reviewer.

model is still omitted when the spec has none, so specs without a model render byte-identically to before. No alias resolution, no effort form — a concrete value crosses as-is, which is what the reverse already expects.

Tests

src/__tests__/agent-format.test.ts, in the renderForCursor describe:

  • renders model: claude-opus-4 into the frontmatter;
  • omits model: when the spec has none (guards the byte-identical path);
  • round-trips through reverseFromCursor without loss.

Suite: 73/73 in agent-format.test.ts (was 70), and the agent delivery suites (agents, doctor-agents-delivery, pull-agents-cleanup, copilot-agents, builtin-agents) all pass — 89/89. npx tsc --noEmit clean; npm run lint 0 warnings under --deny-warnings.

Real-CLI verification (6089aa2)

npm run build, then node dist/index.js pull --force against a sandbox HOME (.cursor/ present) and a local team-repo fixture whose agents/code-reviewer.yaml declares model: claude-opus-4. The only variable is the CLI build:

Before (main) — model dropped (record above). After (this branch):

---
agent_id: code-reviewer
description: Reviews code for the team
model: claude-opus-4
---
You are a careful code reviewer.

Docs: the Cursor section of docs/usage-guide.md (and .zh-CN.md) gained one sentence naming the subagent frontmatter fields, which it did not enumerate before.

)

renderForCursor was the one renderer that dropped spec.model: Claude, the
Codex family and Copilot all write the agent's model into their native
file, and reverseFromCursor reads it back (COMMON_CURSOR_FIELDS whitelists
it), so a team agent with a concrete model ran on Cursor's default model
silently. Tencent#830's design notes name the gap ('Cursor drops model when it
renders agents today') and ask for it as a separate change — this is that
change: write the value verbatim, as the other renderers do. The
model[effort=...] form stays with the alias proposal.
@github-actions

Copy link
Copy Markdown

No findings.

The PR description documents sufficient testing, including a representative real-CLI verification at head commit 6089aa2, plus targeted tests, type checking, and linting. No earlier findings were listed.

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