Commit Graph
2 Commits
Author SHA1 Message Date
yetone 16e373b924 opencode: Zen's free models answer through magpie from Claude Code, Codex and the model test too (ARNO on Discord: mimo-v2.6-flash-free 没有响应: 403 · OpenCode's free tier can only be used from within OpenCode; the user: 只要不是 claude code,都可以尝试伪装一下) — beyond OpenCode's headers (v0.1.615), Zen's free tier takes only a streamed request offering tools named bash and read. A request to a -free model on opencode.ai now always streams upstream, a client that didn't ask for a stream getting the reply collected; a caller's Bash/Read (any case) go as bash/read, as do earlier calls in the history and a forced tool_choice, and calls in the reply get the caller's names back, streamed or not, in each search round too; when bash or read is missing a stub is offered whose description says never to call it, and a call to a stub never reaches the client (a turn with nothing else ends on its text, or a short note, as a stop). Zen lists its -free models again. Paid Zen models and other providers are untouched. Real requests to opencode.ai/zen/v1 with the anonymous key: Claude Code-style Bash/Read streamed and not, Codex-style shell on /v1/responses, no tools non-stream, and the model test all answered 200. TestZenFree* fail without the change. 2026-10-02 09:23:29 +08:00
yetone 3515d99a9c gateway: a request to OpenCode's gateway (Zen or Go) says it is OpenCode's, as OpenCode itself sends it (the user: free Zen models 403 "OpenCode's free tier can only be used from within OpenCode"; mimicking OpenCode is allowed on this route) — magpie sent User-Agent magpie/<version> and its own conversation id (magpie-…) in x-opencode-session. OpenCode (packages/opencode/src/session/llm/request.ts, for a provider whose id starts with "opencode") sends User-Agent opencode/<version>, x-opencode-session (ses_…), x-opencode-request (msg_…), x-opencode-client and x-opencode-project; every request to opencode.ai now carries them: opencode/1.18.34, the conversation as an id of OpenCode's form (one already ses_… goes as it is, any other is made from it, the same for the same conversation), a fresh msg_… id, cli and global. Prompts and body go as the caller sent them; other providers get none of it. Zen's free tier also asks for OpenCode 1.18.0 or newer (426 otherwise), a streamed request, and tools named bash and read: a live request through the gateway with the anonymous key "public" to mimo-v2.6-flash-free went from 403 to 200 for a streamed one offering bash and read (OpenCode's and Pi's), and stays 403 for Claude Code's Bash/Read or no tools, so the free models stay off the list. TestOpenCodeClientHeaders fails without the change; TestOpenCodeGetsConversationSession now expects OpenCode's form. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-02 08:28:35 +08:00