summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-12-04 11:15:30 -0600
committerAiden Cline <[email protected]>2025-12-04 11:15:30 -0600
commit350a32274a24e6f5ca3ea30be114a8171a58270f (patch)
treed55d30422e31333d15ba6ae33c4fd51bfdb1b3e3
parent27c99b46cba5543bb0e7b9e8982140eebfa59041 (diff)
downloadopencode-350a32274a24e6f5ca3ea30be114a8171a58270f.tar.gz
opencode-350a32274a24e6f5ca3ea30be114a8171a58270f.zip
fix: model not being passed correctly to tool
-rw-r--r--packages/opencode/src/session/prompt.ts5
-rw-r--r--packages/opencode/src/tool/read.ts10
2 files changed, 5 insertions, 10 deletions
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index d82cbd718..ebf0a57d0 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -690,7 +690,7 @@ export namespace SessionPrompt {
abort: options.abortSignal!,
messageID: input.processor.message.id,
callID: options.toolCallId,
- extra: input.model,
+ extra: { model: input.model },
agent: input.agent.name,
metadata: async (val) => {
const match = input.processor.partFromToolCall(options.toolCallId)
@@ -907,12 +907,13 @@ export namespace SessionPrompt {
await ReadTool.init()
.then(async (t) => {
+ const model = await Provider.getModel(info.model.providerID, info.model.modelID)
const result = await t.execute(args, {
sessionID: input.sessionID,
abort: new AbortController().signal,
agent: input.agent!,
messageID: info.id,
- extra: { bypassCwdCheck: true, ...info.model },
+ extra: { bypassCwdCheck: true, model },
metadata: async () => {},
})
pieces.push({
diff --git a/packages/opencode/src/tool/read.ts b/packages/opencode/src/tool/read.ts
index 7e01246b5..7d01a1981 100644
--- a/packages/opencode/src/tool/read.ts
+++ b/packages/opencode/src/tool/read.ts
@@ -95,14 +95,8 @@ export const ReadTool = Tool.define("read", {
}
const isImage = isImageFile(filepath)
- const supportsImages = await (async () => {
- if (!ctx.extra?.["providerID"] || !ctx.extra?.["modelID"]) return false
- const providerID = ctx.extra["providerID"] as string
- const modelID = ctx.extra["modelID"] as string
- const model = await Provider.getModel(providerID, modelID).catch(() => undefined)
- if (!model) return false
- return model.capabilities.input.image
- })()
+ const model = ctx.extra?.model as Provider.Model | undefined
+ const supportsImages = model?.capabilities.input.image ?? false
if (isImage) {
if (!supportsImages) {
throw new Error(`Failed to read image: ${filepath}, model may not be able to read images`)