mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-13 19:46:16 +03:00
fix(core): stop running tools from keeping the request hook event alive (#58448)
This commit is contained in:
committed by
GitHub
Unverified
parent
7f4220ecac
commit
7b76b88cb3
@@ -226,20 +226,32 @@ const layer = Layer.effect(
|
||||
initial: loaded.initial,
|
||||
messages: loaded.messages,
|
||||
})
|
||||
const prepared = yield* context.request.primary({
|
||||
session: loaded.session,
|
||||
agent: loaded.agent.id,
|
||||
model: loaded.model,
|
||||
tools: loaded.tools,
|
||||
system: transcript.system,
|
||||
messages: stepLimitReached
|
||||
? [...transcript.messages, Message.assistant(MAX_STEPS_PROMPT)]
|
||||
: transcript.messages,
|
||||
// Keep tool definitions on the final Step to preserve the provider's cached prefix.
|
||||
toolChoice: stepLimitReached ? "none" : undefined,
|
||||
webSocket: "session",
|
||||
inputTokens: SessionCompaction.estimatePrompt(loaded),
|
||||
})
|
||||
const prepared = yield* context.request
|
||||
.primary({
|
||||
session: loaded.session,
|
||||
agent: loaded.agent.id,
|
||||
model: loaded.model,
|
||||
tools: loaded.tools,
|
||||
system: transcript.system,
|
||||
messages: stepLimitReached
|
||||
? [...transcript.messages, Message.assistant(MAX_STEPS_PROMPT)]
|
||||
: transcript.messages,
|
||||
// Keep tool definitions on the final Step to preserve the provider's cached prefix.
|
||||
toolChoice: stepLimitReached ? "none" : undefined,
|
||||
webSocket: "session",
|
||||
inputTokens: SessionCompaction.estimatePrompt(loaded),
|
||||
})
|
||||
.pipe(
|
||||
// The hook event holds every message from before images are bounded, screenshots included, and is a separate
|
||||
// copy once a plugin hook has rewritten it. The step and its tool callbacks live as long as the slowest tool,
|
||||
// so they keep only what they use.
|
||||
Effect.map((prepared) => ({
|
||||
request: prepared.request,
|
||||
options: prepared.options,
|
||||
retry: prepared.retry,
|
||||
executeTool: prepared.executeTool,
|
||||
})),
|
||||
)
|
||||
const outcome = yield* steps.attempt({
|
||||
isLocationClosed: lifecycle.isClosed,
|
||||
sessionID,
|
||||
|
||||
Reference in New Issue
Block a user