<arg_key>command</arg_key>

<arg_value>grep -n "export.*function" message-v2.ts</arg_value>
<arg_key>description</arg_key>
<arg_value>Find exported functions in message-v2.ts</arg_value>
</tool_call>

Co-authored-by: rekram1-node <rekram1-node@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot] 2025-11-18 08:07:37 +00:00
parent 856c87d05c
commit 9c95d57143
6 changed files with 28 additions and 9 deletions

View file

@ -475,7 +475,8 @@ export namespace ACP {
description: agent.description,
}))
const currentModeId = availableModes.find((m) => m.name === "build")?.id ?? availableModes[0].id
const defaultAgentName = await Agent.getDefault()
const currentModeId = availableModes.find((m) => m.name === defaultAgentName)?.id ?? availableModes[0].id
const mcpServers: Record<string, Config.Mcp> = {}
for (const server of params.mcpServers) {
@ -577,7 +578,7 @@ export namespace ACP {
if (!current) {
this.sessionManager.setModel(session.id, model)
}
const agent = session.modeId ?? "build"
const agent = session.modeId ?? (await Agent.getDefault())
const parts: Array<
{ type: "text"; text: string } | { type: "file"; url: string; filename: string; mime: string }

View file

@ -183,6 +183,22 @@ export namespace Agent {
return state().then((x) => x[agent])
}
export async function getDefault() {
const cfg = await Config.get()
const defaultAgent = cfg.default_agent
if (defaultAgent) {
const agents = await state()
if (agents[defaultAgent]) {
return defaultAgent
}
}
// Fallback to build agent if it exists
const agents = await state()
return agents.build ? "build" : Object.keys(agents)[0]
}
export async function list() {
return state().then((x) => Object.values(x))
}

View file

@ -224,7 +224,7 @@ export const RunCommand = cmd({
await sdk.session.command({
path: { id: sessionID },
body: {
agent: args.agent || "build",
agent: args.agent || (await Agent.getDefault()),
model: args.model,
command: args.command,
arguments: message,
@ -235,7 +235,7 @@ export const RunCommand = cmd({
await sdk.session.prompt({
path: { id: sessionID },
body: {
agent: args.agent || "build",
agent: args.agent || (await Agent.getDefault()),
model: modelParam,
parts: [...fileParts, { type: "text", text: message }],
},

View file

@ -497,6 +497,7 @@ export namespace Config {
.catchall(Agent)
.optional()
.describe("@deprecated Use `agent` field instead."),
default_agent: z.string().optional().describe("Default agent to use when no agent is specified"),
agent: z
.object({
plan: Agent.optional(),

View file

@ -164,7 +164,7 @@ export namespace SessionCompaction {
time: {
created: Date.now(),
},
agent: "build",
agent: await Agent.getDefault(),
model: input.model,
})
await Session.updatePart({
@ -197,7 +197,7 @@ export namespace SessionCompaction {
role: "user",
model: input.model,
sessionID: input.sessionID,
agent: "build",
agent: await Agent.getDefault(),
time: {
created: Date.now(),
},

View file

@ -782,7 +782,8 @@ export namespace SessionPrompt {
}
async function createUserMessage(input: PromptInput) {
const agent = await Agent.get(input.agent ?? "build")
const agentName = input.agent ?? (await Agent.getDefault())
const agent = await Agent.get(agentName)
const info: MessageV2.Info = {
id: input.messageID ?? Identifier.ascending("message"),
role: "user",
@ -1289,7 +1290,7 @@ export namespace SessionPrompt {
export async function command(input: CommandInput) {
log.info("command", input)
const command = await Command.get(input.command)
const agentName = command.agent ?? input.agent ?? "build"
const agentName = command.agent ?? input.agent ?? (await Agent.getDefault())
const raw = input.arguments.match(argsRegex) ?? []
const args = raw.map((arg) => arg.replace(quoteTrimRegex, ""))
@ -1428,7 +1429,7 @@ export namespace SessionPrompt {
time: {
created: Date.now(),
},
agent: input.message.info.role === "user" ? input.message.info.agent : "build",
agent: input.message.info.role === "user" ? input.message.info.agent : await Agent.getDefault(),
model: {
providerID: input.providerID,
modelID: input.modelID,