Repository navigation
Conversation
…v1 key
A Markdown agent was classified as v1 whenever its frontmatter contained
any key absent from the v2 schema:
const legacy = Object.keys(markdown.data).some((key) => !agentKeys.has(key))
That is far too broad. The v1 schema is a `StructWithRest`, so it accepts
any unknown key, and its `normalize` folds everything not in v1's
`KNOWN_KEYS` into `options`. `migrateAgent` then forwards `options` as
`request.body`. So a perfectly valid v2 agent that happened to carry a
`name:` or `tools:` key had its entire `permissions:` block moved to
`options` and shipped to the model provider as a junk `request.body`
param, while the agent's real permission list stayed empty.
Effect: the agent keeps every tool it was meant to restrict, with no
warning. `tools:` is the worst trigger because the v1 -> v2 migration
guide tells users to carry it over, so the natural migrated agent is the
one that breaks.
Classify as v1 only when a key that exists solely in v1 is present
(`permission`, `prompt`, `disable`, `maxSteps`, `options`, `temperature`,
`top_p`, `tools`), and let an explicit v2 `permissions:` key always win.
v1 files that only carry `tools:` still take the legacy path, so their
tool gating is preserved.
Regression tests cover a v2 agent with a stray `tools:` and with a stray
`name:`; both assert the rules are applied and that nothing leaks into
`request.body`. Verified failing before the fix and passing after.
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
This was referenced Sep 27, 2026
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Markdown agent was classified as v1 whenever its frontmatter contained any key absent from the v2 schema:
That test is far too broad, and the consequence is not "unknown key ignored" — it is a valid v2
permissions:block being silently discarded and shipped to the model provider as a junk request param.The chain:
legacybecomestruefrom a single stray key.ConfigAgentV1.AgentSchemais aSchema.StructWithRest(..., [Record(String, Any)]), so it accepts anything.normalizemoves every key not in v1'sKNOWN_KEYSintooptions.permissionsis not in that set.migrateAgentdoesrequest: { body: { ...info.options } }.So the v2
permissionsarray lands inrequest.body.permissionsand the agent's real permission list ends up empty.Observed on 2.0.18:
The agent keeps every tool it was written to restrict, with no warning.
tools:is the most damaging trigger precisely because the v1 → v2 migration guide tells users to carry it over, so the natural migrated agent is the broken one.name:triggers it too. Reported in #50598, #50149, #32787.Fix
Classify as v1 only when a key that exists solely in v1 is present, and let an explicit v2
permissions:key always win:Notes on the shape of the fix:
toolsstays inlegacyKeys, so a genuine v1 agent that only carriestools:still takes the legacy path and keeps itstools→permission→ v2permissionsmapping. Dropping it would have been a silent behaviour regression.permissions === undefinedguard is what stops a v2 agent from being dragged down the v1 path, and it also makes the intent explicit: an explicit v2 key wins over the guess.agentKeysis now unused and removed.name:) is now parsed as v2. That is harmless: v1's own migration ignorednametoo, so the resulting agent is equivalent.Tests
Two fixtures in
loads legacy file-based agents from config directories: a v2 agent with a straytools:and one with a strayname:. Both assert the rules are applied and that nothing leaks intorequest.body.Verified failing on the parent commit and passing with the fix.
Full suites:
bun test test/config test/agent test/permission→ 68 pass / 0 fail.packages/schemav1-isolation → 2 pass.tsgo --noEmitclean.oxlintback to the 2 pre-existing warnings on that file.Open question for maintainers
name:is documented as accepted-but-unsupported and "ignored with a warning", but no warning is emitted. Now that stray keys no longer change parsing, would you want a warning for unrecognized frontmatter keys in general? It would have surfaced bothname:and this bug immediately.