mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-23 02:34:21 +01:00
pass through additional agent options to the provider
This commit is contained in:
@@ -14,7 +14,6 @@ export namespace Agent {
|
|||||||
mode: z.union([z.literal("subagent"), z.literal("primary"), z.literal("all")]),
|
mode: z.union([z.literal("subagent"), z.literal("primary"), z.literal("all")]),
|
||||||
topP: z.number().optional(),
|
topP: z.number().optional(),
|
||||||
temperature: z.number().optional(),
|
temperature: z.number().optional(),
|
||||||
options: z.record(z.any()),
|
|
||||||
model: z
|
model: z
|
||||||
.object({
|
.object({
|
||||||
modelID: z.string(),
|
modelID: z.string(),
|
||||||
@@ -23,6 +22,7 @@ export namespace Agent {
|
|||||||
.optional(),
|
.optional(),
|
||||||
prompt: z.string().optional(),
|
prompt: z.string().optional(),
|
||||||
tools: z.record(z.boolean()),
|
tools: z.record(z.boolean()),
|
||||||
|
options: z.record(z.string(), z.any()),
|
||||||
})
|
})
|
||||||
.openapi({
|
.openapi({
|
||||||
ref: "Agent",
|
ref: "Agent",
|
||||||
@@ -73,6 +73,11 @@ export namespace Agent {
|
|||||||
options: {},
|
options: {},
|
||||||
tools: {},
|
tools: {},
|
||||||
}
|
}
|
||||||
|
const { model, prompt, tools, description, temperature, top_p, mode, ...extra } = value
|
||||||
|
item.options = {
|
||||||
|
...item.options,
|
||||||
|
...extra,
|
||||||
|
}
|
||||||
if (value.model) item.model = Provider.parseModel(value.model)
|
if (value.model) item.model = Provider.parseModel(value.model)
|
||||||
if (value.prompt) item.prompt = value.prompt
|
if (value.prompt) item.prompt = value.prompt
|
||||||
if (value.tools)
|
if (value.tools)
|
||||||
@@ -84,11 +89,6 @@ export namespace Agent {
|
|||||||
if (value.temperature != undefined) item.temperature = value.temperature
|
if (value.temperature != undefined) item.temperature = value.temperature
|
||||||
if (value.top_p != undefined) item.topP = value.top_p
|
if (value.top_p != undefined) item.topP = value.top_p
|
||||||
if (value.mode) item.mode = value.mode
|
if (value.mode) item.mode = value.mode
|
||||||
if (value.options)
|
|
||||||
item.options = {
|
|
||||||
...item.options,
|
|
||||||
...value.options,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -173,9 +173,9 @@ export namespace Config {
|
|||||||
tools: z.record(z.string(), z.boolean()).optional(),
|
tools: z.record(z.string(), z.boolean()).optional(),
|
||||||
disable: z.boolean().optional(),
|
disable: z.boolean().optional(),
|
||||||
description: z.string().optional().describe("Description of when to use the agent"),
|
description: z.string().optional().describe("Description of when to use the agent"),
|
||||||
options: z.record(z.string(), z.any()).optional().describe("Additional model options passed through to provider"),
|
|
||||||
mode: z.union([z.literal("subagent"), z.literal("primary"), z.literal("all")]).optional(),
|
mode: z.union([z.literal("subagent"), z.literal("primary"), z.literal("all")]).optional(),
|
||||||
})
|
})
|
||||||
|
.catchall(z.any())
|
||||||
.openapi({
|
.openapi({
|
||||||
ref: "AgentConfig",
|
ref: "AgentConfig",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -360,6 +360,41 @@ The `mode` option can be set to `primary`, `subagent`, or `all`. If no `mode` is
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### Additional options
|
||||||
|
|
||||||
|
Any other options you specify in your agent configuration will be passed through directly to the provider as model options. This allows you to use provider-specific features and parameters.
|
||||||
|
|
||||||
|
```json title="opencode.json"
|
||||||
|
{
|
||||||
|
"agent": {
|
||||||
|
"reasoning": {
|
||||||
|
"model": "openai/gpt-5-turbo",
|
||||||
|
"reasoningEffort": "high",
|
||||||
|
"textVerbosity": "medium"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For example, with OpenAI's reasoning models, you can control the reasoning effort:
|
||||||
|
|
||||||
|
```json title="opencode.json"
|
||||||
|
{
|
||||||
|
"agent": {
|
||||||
|
"deep-thinker": {
|
||||||
|
"description": "Agent that uses high reasoning effort for complex problems",
|
||||||
|
"model": "openai/gpt-5-turbo",
|
||||||
|
"reasoningEffort": "high",
|
||||||
|
"textVerbosity": "low"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
These additional options are model and provider-specific. Check your provider's documentation for available parameters.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Create agents
|
## Create agents
|
||||||
|
|
||||||
You can create new agents using the following command:
|
You can create new agents using the following command:
|
||||||
|
|||||||
Reference in New Issue
Block a user