Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ export const layer = Layer.effect(
})

const createUserMessage = Effect.fn("SessionPrompt.createUserMessage")(function* (input: PromptInput) {
const agentName = input.agent
const agentName = input.agent ?? input.parts.find((p): p is MessageV2.AgentPartInput => p.type === "agent")?.name
const ag = agentName ? yield* agents.get(agentName) : yield* agents.defaultInfo()
if (!ag) {
const available = (yield* agents.list()).filter((a) => !a.hidden).map((a) => a.name)
Expand Down
51 changes: 51 additions & 0 deletions packages/opencode/test/session/prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,57 @@ noLLMServer.instance(
},
)

// Inline agent mention uses agent's configured model

it.instance(
"inline @agent mention uses the agent's configured model instead of default",
() =>
Effect.gen(function* () {
const prompt = yield* SessionPrompt.Service
const sessions = yield* Session.Service
const session = yield* sessions.create({})

const msg = yield* prompt.prompt({
sessionID: session.id,
noReply: true,
parts: [
{ type: "agent", name: "other" },
{ type: "text", text: "hello from other agent" },
],
})

if (msg.info.role !== "user") throw new Error("expected user message")
expect(msg.info.model.providerID).toBe(ProviderID.make("test"))
expect(msg.info.model.modelID).toBe(ModelID.make("test-model-2"))

yield* sessions.remove(session.id)
}),
{
config: {
...cfg,
provider: {
...cfg.provider,
test: {
...cfg.provider.test,
models: {
...cfg.provider.test.models,
"test-model-2": {
...cfg.provider.test.models["test-model"],
id: "test-model-2",
name: "Test Model 2",
},
},
},
},
agent: {
other: {
model: "test/test-model-2",
},
},
},
},
)

// Agent / command resolution errors

noLLMServer.instance(
Expand Down
Loading