Skip to content

Commit ace2ada

Browse files
committed
fix: Codespaces — skip GITHUB_TOKEN auto-enable for github-models, cap retries, fix phantom command
Closes #413 - Skip auto-enabling `github-models` and `github-copilot` providers when `CODESPACES=true` and only `GITHUB_TOKEN` is available (the Codespace machine token lacks model-inference permissions, causing immediate 429s) - Cap retry attempts at 5 (`RETRY_MAX_ATTEMPTS`) to prevent infinite retry loops with 30+ minute backoff - Replace phantom `/discover-and-add-mcps` toast with actionable message ("Ask the assistant to add them") - Add `.devcontainer/` config (Node 22, Bun 1.3.10) for reproducible Codespace environments - Update docs to reference `mcp_discover` tool instead of non-existent slash command
1 parent 59f5a8e commit ace2ada

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

packages/opencode/test/provider/provider.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,4 +2330,28 @@ test("github-models is available when GITHUB_TOKEN set without CODESPACES", asyn
23302330
},
23312331
})
23322332
})
2333+
2334+
test("github-copilot is excluded when CODESPACES=true and only GITHUB_TOKEN is set", async () => {
2335+
await using tmp = await tmpdir({
2336+
init: async (dir) => {
2337+
await Bun.write(
2338+
path.join(dir, "opencode.json"),
2339+
JSON.stringify({
2340+
$schema: "https://altimate.ai/config.json",
2341+
}),
2342+
)
2343+
},
2344+
})
2345+
await Instance.provide({
2346+
directory: tmp.path,
2347+
init: async () => {
2348+
Env.set("GITHUB_TOKEN", "ghu_fake_codespace_token")
2349+
Env.set("CODESPACES", "true")
2350+
},
2351+
fn: async () => {
2352+
const providers = await Provider.list()
2353+
expect(providers["github-copilot"]).toBeUndefined()
2354+
},
2355+
})
2356+
})
23332357
// altimate_change end

packages/opencode/test/session/retry.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ describe("session.retry.delay", () => {
9292
})
9393

9494
describe("session.retry.max_attempts", () => {
95-
test("RETRY_MAX_ATTEMPTS is defined and reasonable", () => {
96-
expect(SessionRetry.RETRY_MAX_ATTEMPTS).toBeDefined()
97-
expect(SessionRetry.RETRY_MAX_ATTEMPTS).toBeGreaterThanOrEqual(3)
98-
expect(SessionRetry.RETRY_MAX_ATTEMPTS).toBeLessThanOrEqual(10)
95+
test("RETRY_MAX_ATTEMPTS is 5", () => {
96+
expect(SessionRetry.RETRY_MAX_ATTEMPTS).toBe(5)
9997
})
10098
})
10199

0 commit comments

Comments
 (0)