GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add mistral affinity header test · anomalyco/opencode@d734335

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode/test/session
    • llm.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/test/session/llm.test.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/test/session/llm.test.ts
+109Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,4 +688,113 @@ describe("session.llm.stream", () => {
688688
},
689689
})
690690
})
691+
692+
test("sends stable mistral affinity header", async () => {
693+
const server = state.server
694+
if (!server) {
695+
throw new Error("Server not initialized")
696+
}
697+
698+
const providerID = "mistral"
699+
const modelID = "mistral-large-2512"
700+
const fixture = await loadFixture(providerID, modelID)
701+
const model = fixture.model
702+
703+
const requestOne = waitRequest(
704+
"/chat/completions",
705+
new Response(createChatStream("Hello"), {
706+
status: 200,
707+
headers: { "Content-Type": "text/event-stream" },
708+
}),
709+
)
710+
711+
const requestTwo = waitRequest(
712+
"/chat/completions",
713+
new Response(createChatStream("Hi"), {
714+
status: 200,
715+
headers: { "Content-Type": "text/event-stream" },
716+
}),
717+
)
718+
719+
await using tmp = await tmpdir({
720+
init: async (dir) => {
721+
await Bun.write(
722+
path.join(dir, "opencode.json"),
723+
JSON.stringify({
724+
$schema: "https://opencode.ai/config.json",
725+
enabled_providers: [providerID],
726+
provider: {
727+
[providerID]: {
728+
options: {
729+
apiKey: "test-mistral-key",
730+
baseURL: `${server.url.origin}/v1`,
731+
},
732+
},
733+
},
734+
}),
735+
)
736+
},
737+
})
738+
739+
await Instance.provide({
740+
directory: tmp.path,
741+
fn: async () => {
742+
const resolved = await Provider.getModel(providerID, model.id)
743+
const sessionID = "session-test-mistral"
744+
const agent = {
745+
name: "test",
746+
mode: "primary",
747+
options: {},
748+
permission: [{ permission: "*", pattern: "*", action: "allow" }],
749+
temperature: 0.4,
750+
} satisfies Agent.Info
751+
752+
const user = {
753+
id: "user-mistral",
754+
sessionID,
755+
role: "user",
756+
time: { created: Date.now() },
757+
agent: agent.name,
758+
model: { providerID, modelID: resolved.id },
759+
} satisfies MessageV2.User
760+
761+
const streamOne = await LLM.stream({
762+
user,
763+
sessionID,
764+
model: resolved,
765+
agent,
766+
system: ["You are a helpful assistant."],
767+
abort: new AbortController().signal,
768+
messages: [{ role: "user", content: "Hello" }],
769+
tools: {},
770+
})
771+
772+
for await (const _ of streamOne.fullStream) {
773+
}
774+
775+
const streamTwo = await LLM.stream({
776+
user,
777+
sessionID,
778+
model: resolved,
779+
agent,
780+
system: ["You are a helpful assistant."],
781+
abort: new AbortController().signal,
782+
messages: [{ role: "user", content: "Hello again" }],
783+
tools: {},
784+
})
785+
786+
for await (const _ of streamTwo.fullStream) {
787+
}
788+
789+
const captureOne = await requestOne
790+
const captureTwo = await requestTwo
791+
792+
const affinityOne = captureOne.headers.get("x-affinity")
793+
const affinityTwo = captureTwo.headers.get("x-affinity")
794+
795+
expect(affinityOne).toBeTruthy()
796+
expect(affinityOne).toBe(affinityTwo)
797+
},
798+
})
799+
})
691800
})

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.