fix(core): scope v2 prompt cache by session (#31036)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot] 2026-06-05 19:11:32 -04:00 committed by GitHub
parent 3e704d096f
commit 7c6adcf60f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -213,6 +213,7 @@ export const layer = Layer.effect(
const context = entries.map((entry) => entry.message)
const request = LLM.request({
model,
providerOptions: { openai: { promptCacheKey: session.id } },
system: [agent.info?.system, system.baseline]
.filter((part): part is string => part !== undefined && part.length > 0)
.map(SystemPart.make),

View File

@ -2812,6 +2812,10 @@ describe("SessionRunnerLLM", () => {
yield* Effect.yieldNow
expect(requests).toHaveLength(2)
expect(requests.map((request) => request.providerOptions?.openai?.promptCacheKey)).toEqual([
sessionID,
otherSessionID,
])
yield* Deferred.succeed(streamGate, undefined)
yield* Fiber.join(first)
yield* Fiber.join(second)