fix(hooks): apply Sisyphus GPT-5.5 variant

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-27 15:33:14 +09:00
parent f1a11f2c92
commit a696c8a67c
2 changed files with 90 additions and 21 deletions
+63 -20
View File
@@ -1,4 +1,7 @@
/// <reference types="bun-types" />
import { describe, expect, spyOn, test } from "bun:test"
import type { PluginInput } from "@opencode-ai/plugin"
import { _resetForTesting, updateSessionAgent } from "../../features/claude-code-session-state"
import { getAgentDisplayName } from "../../shared/agent-display-names"
import { createNoSisyphusGptHook } from "./index"
@@ -6,20 +9,29 @@ import { createNoSisyphusGptHook } from "./index"
const SISYPHUS_DISPLAY = getAgentDisplayName("sisyphus")
const HEPHAESTUS_DISPLAY = getAgentDisplayName("hephaestus")
function createOutput() {
type HookOutput = {
message: { agent?: string; variant?: string; [key: string]: unknown }
parts: unknown[]
}
function createOutput(): HookOutput {
return {
message: {},
parts: [],
}
}
function createHookContext(showToast: (input: unknown) => Promise<unknown>): PluginInput {
return {
client: { tui: { showToast } },
} as unknown as PluginInput
}
describe("no-sisyphus-gpt hook", () => {
test("shows toast on every chat.message when sisyphus uses gpt model", async () => {
// given - sisyphus (display name) with gpt model
const showToast = spyOn({ fn: async () => ({}) }, "fn")
const hook = createNoSisyphusGptHook({
client: { tui: { showToast } },
} as any)
const hook = createNoSisyphusGptHook(createHookContext(showToast))
const output1 = createOutput()
const output2 = createOutput()
@@ -40,7 +52,8 @@ describe("no-sisyphus-gpt hook", () => {
expect(showToast).toHaveBeenCalledTimes(2)
expect(output1.message.agent).toBe("hephaestus")
expect(output2.message.agent).toBe("hephaestus")
expect(showToast.mock.calls[0]?.[0]).toMatchObject({
const firstToastCall = (showToast.mock.calls as Array<Array<unknown>>)[0]?.[0]
expect(firstToastCall).toMatchObject({
body: {
title: "NEVER Use Sisyphus with GPT",
message: expect.stringContaining("For other GPT models, always use Hephaestus."),
@@ -52,9 +65,7 @@ describe("no-sisyphus-gpt hook", () => {
test("does not show toast for gpt-5.4 model (Sisyphus has specialized support)", async () => {
// given - sisyphus with gpt-5.4 model (should be allowed)
const showToast = spyOn({ fn: async () => ({}) }, "fn")
const hook = createNoSisyphusGptHook({
client: { tui: { showToast } },
} as any)
const hook = createNoSisyphusGptHook(createHookContext(showToast))
const output = createOutput()
@@ -73,9 +84,7 @@ describe("no-sisyphus-gpt hook", () => {
test("does not show toast for gpt-5.5 model (native Sisyphus support)", async () => {
// given - sisyphus with gpt-5.5 model (should be allowed)
const showToast = spyOn({ fn: async () => ({}) }, "fn")
const hook = createNoSisyphusGptHook({
client: { tui: { showToast } },
} as any)
const hook = createNoSisyphusGptHook(createHookContext(showToast))
const output = createOutput()
@@ -91,12 +100,50 @@ describe("no-sisyphus-gpt hook", () => {
expect(output.message.agent).toBeUndefined()
})
test("sets medium variant for gpt-5.5 model when native Sisyphus support is used", async () => {
// given - sisyphus with gpt-5.5 model and no selected variant
const showToast = spyOn({ fn: async () => ({}) }, "fn")
const hook = createNoSisyphusGptHook(createHookContext(showToast))
const output = createOutput()
// when - chat.message runs with gpt-5.5
await hook["chat.message"]?.({
sessionID: "ses_gpt55_medium",
agent: SISYPHUS_DISPLAY,
model: { providerID: "openai", modelID: "gpt-5.5" },
}, output)
// then - Sisyphus stays active and receives its configured GPT-5.5 variant
expect(showToast).toHaveBeenCalledTimes(0)
expect(output.message.agent).toBeUndefined()
expect(output.message.variant).toBe("medium")
})
test("preserves selected variant for gpt-5.5 model when native Sisyphus support is used", async () => {
// given - sisyphus with gpt-5.5 model and a selected variant
const showToast = spyOn({ fn: async () => ({}) }, "fn")
const hook = createNoSisyphusGptHook(createHookContext(showToast))
const output: HookOutput = { message: { variant: "high" }, parts: [] }
// when - chat.message runs with gpt-5.5
await hook["chat.message"]?.({
sessionID: "ses_gpt55_high",
agent: SISYPHUS_DISPLAY,
model: { providerID: "openai", modelID: "gpt-5.5" },
}, output)
// then - user-selected variant is not overwritten
expect(showToast).toHaveBeenCalledTimes(0)
expect(output.message.agent).toBeUndefined()
expect(output.message.variant).toBe("high")
})
test("does not show toast for non-gpt model", async () => {
// given - sisyphus with claude model
const showToast = spyOn({ fn: async () => ({}) }, "fn")
const hook = createNoSisyphusGptHook({
client: { tui: { showToast } },
} as any)
const hook = createNoSisyphusGptHook(createHookContext(showToast))
const output = createOutput()
@@ -115,9 +162,7 @@ describe("no-sisyphus-gpt hook", () => {
test("does not show toast for non-sisyphus agent", async () => {
// given - hephaestus with gpt model
const showToast = spyOn({ fn: async () => ({}) }, "fn")
const hook = createNoSisyphusGptHook({
client: { tui: { showToast } },
} as any)
const hook = createNoSisyphusGptHook(createHookContext(showToast))
const output = createOutput()
@@ -138,9 +183,7 @@ describe("no-sisyphus-gpt hook", () => {
_resetForTesting()
updateSessionAgent("ses_4", SISYPHUS_DISPLAY)
const showToast = spyOn({ fn: async () => ({}) }, "fn")
const hook = createNoSisyphusGptHook({
client: { tui: { showToast } },
} as any)
const hook = createNoSisyphusGptHook(createHookContext(showToast))
const output = createOutput()