Skip to content

Commit 7202b3a

Browse files
fix: ensure that openai oauth works for agent create cmd, use temporary hack (#21749)
Co-authored-by: OpeOginni <brightoginni123@gmail.com>
1 parent 35b44df commit 7202b3a

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

packages/opencode/src/agent/agent.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,10 @@ export namespace Agent {
341341
)
342342
const existing = yield* InstanceState.useEffect(state, (s) => s.list())
343343

344+
// TODO: clean this up so provider specific logic doesnt bleed over
345+
const authInfo = yield* auth.get(model.providerID).pipe(Effect.orDie)
346+
const isOpenaiOauth = model.providerID === "openai" && authInfo?.type === "oauth"
347+
344348
const params = {
345349
experimental_telemetry: {
346350
isEnabled: cfg.experimental?.openTelemetry,
@@ -350,12 +354,14 @@ export namespace Agent {
350354
},
351355
temperature: 0.3,
352356
messages: [
353-
...system.map(
354-
(item): ModelMessage => ({
355-
role: "system",
356-
content: item,
357-
}),
358-
),
357+
...(isOpenaiOauth
358+
? []
359+
: system.map(
360+
(item): ModelMessage => ({
361+
role: "system",
362+
content: item,
363+
}),
364+
)),
359365
{
360366
role: "user",
361367
content: `Create an agent configuration based on this request: \"${input.description}\".\n\nIMPORTANT: The following identifiers already exist and must NOT be used: ${existing.map((i) => i.name).join(", ")}\n Return ONLY the JSON object, no other text, do not wrap in backticks`,
@@ -369,13 +375,12 @@ export namespace Agent {
369375
}),
370376
} satisfies Parameters<typeof generateObject>[0]
371377

372-
// TODO: clean this up so provider specific logic doesnt bleed over
373-
const authInfo = yield* auth.get(model.providerID).pipe(Effect.orDie)
374-
if (model.providerID === "openai" && authInfo?.type === "oauth") {
378+
if (isOpenaiOauth) {
375379
return yield* Effect.promise(async () => {
376380
const result = streamObject({
377381
...params,
378382
providerOptions: ProviderTransform.providerOptions(resolved, {
383+
instructions: system.join("\n"),
379384
store: false,
380385
}),
381386
onError: () => {},

0 commit comments

Comments
 (0)