-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: add tool prompt override support in .continuerc.json #9314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shanevcantwell
wants to merge
4
commits into
continuedev:main
Choose a base branch
from
shanevcantwell:feature/tool-prompt-overrides
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+459
−4
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
df3e417
feat: add tool prompt overrides support in YAML model config
shanevcantwell 0286f63
feat(cli): add tool prompt overrides support for CLI parity
shanevcantwell d93e216
Merge branch 'main' into feature/tool-prompt-overrides
shanevcantwell be20726
fix: restore tool override usage after merge conflict
shanevcantwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { ConfigValidationError } from "@continuedev/config-yaml"; | ||
| import { Tool, ToolOverride } from ".."; | ||
|
|
||
| export interface ApplyToolOverridesResult { | ||
| tools: Tool[]; | ||
| errors: ConfigValidationError[]; | ||
| } | ||
|
|
||
| /** | ||
| * Applies tool overrides from config to the list of tools. | ||
| * Overrides can modify tool descriptions, display titles, action phrases, | ||
| * system message descriptions, or disable tools entirely. | ||
| */ | ||
| export function applyToolOverrides( | ||
| tools: Tool[], | ||
| overrides: ToolOverride[] | undefined, | ||
| ): ApplyToolOverridesResult { | ||
| if (!overrides?.length) { | ||
| return { tools, errors: [] }; | ||
| } | ||
|
|
||
| const errors: ConfigValidationError[] = []; | ||
| const toolsByName = new Map(tools.map((t) => [t.function.name, t])); | ||
|
|
||
| for (const override of overrides) { | ||
| const tool = toolsByName.get(override.name); | ||
|
|
||
| if (!tool) { | ||
| errors.push({ | ||
| fatal: false, | ||
| message: `Tool override "${override.name}" does not match any known tool. Available tools: ${Array.from(toolsByName.keys()).join(", ")}`, | ||
| }); | ||
| continue; | ||
| } | ||
|
|
||
| if (override.disabled) { | ||
| toolsByName.delete(override.name); | ||
| continue; | ||
| } | ||
|
|
||
| const updatedTool: Tool = { | ||
| ...tool, | ||
| function: { | ||
| ...tool.function, | ||
| description: override.description ?? tool.function.description, | ||
| }, | ||
| displayTitle: override.displayTitle ?? tool.displayTitle, | ||
| wouldLikeTo: override.wouldLikeTo ?? tool.wouldLikeTo, | ||
| isCurrently: override.isCurrently ?? tool.isCurrently, | ||
| hasAlready: override.hasAlready ?? tool.hasAlready, | ||
| }; | ||
|
|
||
| if (override.systemMessageDescription) { | ||
| updatedTool.systemMessageDescription = { | ||
| prefix: | ||
| override.systemMessageDescription.prefix ?? | ||
| tool.systemMessageDescription?.prefix ?? | ||
| "", | ||
| exampleArgs: | ||
| override.systemMessageDescription.exampleArgs ?? | ||
| tool.systemMessageDescription?.exampleArgs, | ||
| }; | ||
| } | ||
|
|
||
| toolsByName.set(override.name, updatedTool); | ||
| } | ||
|
|
||
| return { tools: Array.from(toolsByName.values()), errors }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.