Skip to content

fix: merge user-configured svelte-file-editor agent settings#176

Merged
paoloricciuti merged 15 commits intosveltejs:mainfrom
momoshell:fix/merge-user-svelte-agent-config
Mar 11, 2026
Merged

fix: merge user-configured svelte-file-editor agent settings#176
paoloricciuti merged 15 commits intosveltejs:mainfrom
momoshell:fix/merge-user-svelte-agent-config

Conversation

@momoshell
Copy link
Contributor

Description

The @sveltejs/opencode plugin was unconditionally overwriting the svelte-file-editor agent configuration, preventing users from customizing settings like model, variant, or other agent properties.

This PR changes the behavior to merge user configuration with plugin defaults, with user config taking precedence.

Reproduction

  1. Create or edit your OpenCode configuration (~/.config/opencode/opencode.json):
{
  "agent": {
    "svelte-file-editor": {
      "mode": "subagent",
      "model": "anthropic/claude-sonnet-4-20250514",
      "variant": "coding"
    }
  }
}
  1. Run OpenCode in a Svelte project with the plugin enabled
  2. Before fix: The configured model was ignored - the subagent inherited the model from the invoking primary agent
  3. After fix: User configuration is preserved and merged with plugin defaults

Changes

  • Extract the default agent config into a default_config variable
  • Merge user's existing svelte-file-editor config with defaults using spread operator
  • User config takes precedence over defaults

Fixes #175

Previously, the plugin unconditionally overwrote the svelte-file-editor
agent configuration, preventing users from customizing settings like
model, variant, or other agent properties.

Now user configuration is merged with plugin defaults, with user config
taking precedence. This allows users to override model/variant in their
opencode.json:

{
  "agent": {
    "svelte-file-editor": {
      "model": "anthropic/claude-sonnet-4-20250514",
      "variant": "coding"
    }
  }
}

Fixes sveltejs#175
@vercel
Copy link

vercel bot commented Mar 7, 2026

Someone is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link

changeset-bot bot commented Mar 7, 2026

🦋 Changeset detected

Latest commit: 1968504

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/opencode Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Allows users to configure model and variant for the svelte-file-editor
agent directly in svelte.json instead of opencode.json.

Users can now set:
{
  "model": "anthropic/claude-sonnet-4-20250514",
  "variant": "coding"
}

in ~/.config/opencode/svelte.json or project-local .opencode/svelte.json

Fixes sveltejs#175
@paoloricciuti
Copy link
Member

Hey the feature request is absolutely valid...however I don't think this is the right solution...the open code plugin for svelte has it's own configuration file and it would feel weird to have part of the configuration in svelte.json and part in the opencode.json config.

This would also mean that if you are using the open code schema you would get warnings if you don't fill all the information (that is already filled by the plugin). I would say the best way is that we add the configuration object in the svelte.json file and we apply the configuration when adding it. I can do it if you want but if you want to update this PR I'll happily merge that.

@momoshell
Copy link
Contributor Author

Hi @paoloricciuti, thank you for your very prompt response 🙏
Yes, after I've created the PR, I realised the same thing, and pushed the new commit that leverages svelte.json file. Literally just a moment before your response 😄

Is this new one a proper solution, or just the beginning of one?

@paoloricciuti
Copy link
Member

@momoshell uh sorry didn't realize... I think it's just the beginning of the solution 😅

This will basically unify all the agents into the same option which is fine for now but might be annoying in the future. I'd say we can basically have the same customizations on a per-agent level. So the idea would be that in svelte.json you write something like this

{
"agent": {
		"svelte-file-editor": {
			// config for svelte-file-editor
		}
	}
}

this will allow for all the customization even for future agents. I would keep the config schema "wide" merging the current schema with a looseObject record of string -> config and then update the schema generation script to actually provide intellisense for the available agents. You can take inspiration from #174 to see how I did kinda the same for skills.

Momochiro added 4 commits March 8, 2026 08:48
Only agent configuration is being added, not skills.
Took inspiration from PR sveltejs#174 for the intellisense pattern only.
Don't mention specific agent names in the description, similar to how
skills schema doesn't mention specific skill names. Intellisense for
known agents is still provided via the schema generator.
svelte.json is the canonical place for svelte-specific configuration,
so it should take precedence over any agent config in opencode.json.
svelte.json is the sole source of truth for svelte agent configuration.
@momoshell
Copy link
Contributor Author

@paoloricciuti thank you for your suggestions, great stuff btw!

Here's what I've tried to replicate in related files:

  1. packages/opencode/config.ts
  • Added agent field with per-agent configuration schema supporting model and variant properties
  • Schema uses v.record(v.string(), agent_config_schema) for extensibility
  1. packages/opencode/scripts/generate-schema.ts
  1. packages/opencode/index.ts
  • Reads agent config from mcp_config.agent['svelte-file-editor']
  • svelte.json is the sole source of truth for agent configuration (not opencode.json)
  1. packages/opencode/schema.json
  • Regenerated with a new agent property

import path from 'node:path';

// Known agents that can be configured
const known_agents = ['svelte-file-editor'];
Copy link
Member

Choose a reason for hiding this comment

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

We can read the known agents with fs from the ./tools/agents folder so we don't have to hard code it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's definitely much better.
Addressed with 94953dd

v.object({
enabled: v.optional(v.boolean()),
}),
agent: v.pipe(
Copy link
Member

Choose a reason for hiding this comment

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

We should re-use the same subagent key otherwise it will be confusing to have separate config for the same thing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I got it, changes are here: a83d466

Copy link
Member

Choose a reason for hiding this comment

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

Thanks... I'll review it properly as soon as I'm back at the desk (it could be tomorrow) 🙏🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, @paoloricciuti, this was the best PR review experience I have ever had :)
And being this dialed-in is legendary.

Momochiro and others added 5 commits March 8, 2026 17:56
Instead of hardcoding the list of known agents, discover them by reading
.md files from the tools/agents directory. This follows the same pattern
used for skill discovery and makes it easier to add new agents.
Consolidates agent configuration under subagent.agents to avoid
confusion between separate 'subagent' and 'agent' config keys.
Users now configure agents via subagent.agents instead of a
top-level agent key.
@svelte-docs-bot
Copy link

Comment on lines +9 to +16
model: v.pipe(
v.optional(v.string()),
v.description('Model identifier for the agent (e.g., "anthropic/claude-sonnet-4-20250514")'),
),
variant: v.pipe(
v.optional(v.string()),
v.description('Variant identifier for the agent (e.g., "coding")'),
),
Copy link
Member

Choose a reason for hiding this comment

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

I was working on this to actually merge it but I was thinking...should we also give more flexibility here? Maybe someone actually wants to change the temperature or the maxSteps. I don't think soeone should change tools or permissions but maybe those things we could add.

Copy link
Contributor Author

@momoshell momoshell Mar 10, 2026

Choose a reason for hiding this comment

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

Maybe we should. I'm not really smart here, but I think that it boils down to personal preference.
Speaking of which, mine is to use config files [like opencode.json] to define providers, models, and variants.
Everything else, like temperature or specific permission, I keep in the prompt .md files.

And then, on the other side of things is what you've just mentioned. I guess it wouldn't hurt much to add a few additional fields, right?

Copy link
Member

Choose a reason for hiding this comment

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

But temperature is a parameter of the subagent...I think we should add those too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree then, flexibility is always appreciated 👏

Copy link
Member

Choose a reason for hiding this comment

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

@momoshell pushed the final change...I've removed variant because it doesn't seem to be an actual configuration option for agents

Copy link
Contributor Author

@momoshell momoshell Mar 11, 2026

Choose a reason for hiding this comment

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

@paoloricciuti nice update, thank you very much.

I've removed variant because it doesn't seem to be an actual configuration option for agents

Just to verify, are we talking about the same thing, because this is the config param I've been using for quite some time now. Example from opencode's docs:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "openai": {
      "models": {
        "gpt-5": {
          "variants": {
            "thinking": {
              "reasoningEffort": "high",
              "textVerbosity": "low",
            },
            "fast": {
              "disabled": true,
            },
          },
        },
      },
    },
  },
}

from their Models page

Copy link
Member

Choose a reason for hiding this comment

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

That is a configuration for the models not for the subagent...the subagent model only get the string

Copy link
Contributor Author

@momoshell momoshell Mar 11, 2026

Choose a reason for hiding this comment

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

Ahh, ok, now I get what you've meant, sry for the confusion.
All good then, thanks

@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mcp Ready Ready Preview, Comment Mar 10, 2026 10:23pm

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@sveltejs/mcp@176
npm i https://pkg.pr.new/@sveltejs/opencode@176

commit: 8593ad6

@paoloricciuti paoloricciuti merged commit 27a2fc5 into sveltejs:main Mar 11, 2026
7 checks passed
@github-actions github-actions bot mentioned this pull request Mar 10, 2026
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.

Plugin overwrites user-configured svelte-file-editor agent settings

2 participants