Skip to content

chore: sync upstream fantasy v0.48.3 into coder_2_33 - #86

Merged
ethanndickson merged 34 commits into
coder_2_33from
ethan/sync-upstream-v0.48.3
Dec 1, 2026
Merged

ethanndickson merged 34 commits into
coder_2_33from
ethan/sync-upstream-v0.48.3

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Relates to coder/coder#31714

This syncs coder_2_33 with upstream charmbracelet/fantasy main at a00cb28 (v0.48.3 plus charmbracelet#459), which is 29 upstream commits since the last sync in #72. The one I'm after is charmbracelet#386. Our Chat Completions reasoning check stopped at gpt-5, so an Azure gpt-6-luna model in coder/coder fails with 'max_tokens' is not supported with this model.

Please merge this with "Create a merge commit", not squash, same as #72, so the next sync only has to deal with new upstream commits.

The conflict resolutions are in the merge commit message. The main ones are that upstream's reasoning model check (charmbracelet#386) replaces the name checks from #57, whilst the reasoning model override from #57 stays on both transports, and that upstream's Gemini tool result media (charmbracelet#463) replaces ours from #58. Anthropic's TotalTokens now counts cache tokens (charmbracelet#457), on top of our per-request usage from #50.

As in #72, the commit after the merge keeps us on what coder/coder ships, i.e. the coder forks of anthropic-sdk-go and openai-go, Go 1.26 and kronk v1.31.5. kaptinlin/jsonschema also stays at v0.9.8, as v0.9.10 needs Go 1.27. The commit after that updates two of our tests for upstream's new behaviour. The last two get CI going again: govulncheck runs with Go 1.26.11, and the lint job is granted the permissions its workflow asks for (checks: write and pull-requests: read), which the default token no longer has.

A few things change for chatd in coder/coder:

  • On Chat Completions, gpt-6 to gpt-9, codex- and computer-use names are now reasoning models. -chat names, e.g. gpt-5-chat, no longer are, so they keep temperature, and the OpenAI-compatible providers send them max_tokens again.
  • On Responses, every model is a reasoning model unless its name contains gpt-3, gpt-4, chatgpt- or -chat. Unknown names used to be non-reasoning. The override from feat(providers/openai): allow reasoning-model overrides and recognize gpt-6+ #57 still wins.
  • We no longer drop the flex and priority service tiers for models the old name checks didn't know, e.g. gpt-6. They're sent as configured.
  • Anthropic's TotalTokens includes cache read and cache creation tokens.
  • A Chat Completions stream that ends abnormally (length, content_filter, an error or an unknown finish reason) with no tool calls now emits a warnings part before the finish (fix(providers): surface abnormal finish reasons in text-only streams charmbracelet/fantasy#444).

Request compression (charmbracelet#425) is opt-in, so nothing changes there.

When coder/coder picks this up, go mod tidy bumps a few dependencies (the AWS SDK, google.golang.org/api, google.golang.org/genai, etc.). Five chatd tests also need new expectations for the above: three Anthropic total_tokens values, the unknown model row on Responses, and the debug panel's field coverage for StreamPart.ReceivedAt and CallWarning.RawFinishReason.

I've pointed coder/coder at this PR, and with those updated the chatd and aibridge tests pass, as does a repo-wide go build. That includes a new row for the reporter's setup (provider azure, model gpt-6-luna), which fails on today's pin. I haven't run this against a real provider.

ardan-bkennedy and others added 30 commits October 30, 2026 09:59
Update both module dependency graphs and use Kronk's relocated logger and session-store factory types.

Amp-Thread-ID: https://ampcode.com/threads/T-01a187f1-ff83-71d7-ba5c-859fec8b0cd9

Co-authored-by: Amp <amp@ampcode.com>
Bumps the all group with 3 updates: [cloud.google.com/go/auth](https://github.com/googleapis/google-cloud-go), [github.com/anthropics/anthropic-sdk-go](https://github.com/anthropics/anthropic-sdk-go) and [google.golang.org/genai](https://github.com/googleapis/go-genai).


Updates `cloud.google.com/go/auth` from 0.24.1 to 0.24.2
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](googleapis/google-cloud-go@auth/v0.24.1...auth/v0.24.2)

Updates `github.com/anthropics/anthropic-sdk-go` from 1.75.0 to 1.84.0
- [Release notes](https://github.com/anthropics/anthropic-sdk-go/releases)
- [Changelog](https://github.com/anthropics/anthropic-sdk-go/blob/main/CHANGELOG.md)
- [Commits](anthropics/anthropic-sdk-go@v1.75.0...v1.84.0)

Updates `google.golang.org/genai` from 1.71.0 to 1.76.0
- [Release notes](https://github.com/googleapis/go-genai/releases)
- [Changelog](https://github.com/googleapis/go-genai/blob/main/CHANGELOG.md)
- [Commits](googleapis/go-genai@v1.71.0...v1.76.0)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/auth
  dependency-version: 0.24.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: github.com/anthropics/anthropic-sdk-go
  dependency-version: 1.84.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: google.golang.org/genai
  dependency-version: 1.76.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…harmbracelet#444)

A stream ending in length, content_filter, error, or an unrecognized
finish reason used to produce a normal Finish with no warning when the
turn had no tool calls, so clients could not tell a truncated answer
from a complete one. Emit a Warnings part naming the cause and carrying
the provider's raw finish-reason string via CallWarning.RawFinishReason.

Also close open reasoning blocks on the finish chunk in the openrouter
hook, where a finish with empty content and no reasoning_details used to
leave the block open and drop it from the recorded step content.

Assisted-by: Crush:prism
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Kieran Klukas <kieran@dunkirk.sh>
…verflow

Parasail reports a prompt that is already too large on its own with
"This model's maximum context length is N tokens. However, your prompt
contains M input tokens, which exceeds this limit even without any
output tokens", which was not matched, so a context overflow looked like
a generic provider failure. Capture the maximum and input token counts
so it is handled like the other providers.

Assisted-by: Crush:prism
* Crush PR: charmbracelet/crush#4100

Servers that read compressed uploads can save roughly four times the bytes a
client re-sends on every turn. Off by default, and a body the server could not
read is replayed uncompressed on a 400 or 415, so an endpoint without support
behaves exactly as it did before. Other statuses are never replayed: they can
follow work that was already charged.

Assisted-by: Crush:prism
WithRequestCompression now takes a preference list of encodings
(gzip, brotli via molecule-man/go-brrr at quality 1), trying each
before falling back to a plain body. The first encoding the server
accepts is remembered, so a refused encoding is paid once per client
rather than once per request. No arguments keeps the gzip-only
behavior it always had.

Assisted-by: Crush:prism
Update both module dependency graphs and remove WithSessionStoreFactory, which Kronk no longer supports. IMC checkpoints now use internal RAM storage.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1d1c0-dc6c-7422-9331-d93ce87a9dd2
Co-authored-by: Amp <amp@ampcode.com>
…t#442)

Gemini repeats the running usageMetadata totals on every streamed chunk,
but Stream and StreamObject added OutputTokens, ReasoningTokens and
CacheReadTokens across chunks, inflating the reported usage (10, 20, 30
came out as 60). Keep the latest chunk's usage instead, as InputTokens
already effectively did.
Use gzip level 6 and brotli level 4 for compressed requests.

Assisted-by: Crush:kimi-k3.1-pro
Anthropic's input_tokens excludes cache_read and cache_creation tokens, so TotalTokens (input+output) undercounted any cached call. Add both to Generate and Stream, matching the OpenAI and Google providers.

Signed-off-by: Alex <alex.castillog33@gmail.com>
Update both module dependency graphs and migrate the moon example to the supported Charm modules for compatibility with Kronk's newer ANSI dependency.

Amp-Thread-ID: https://ampcode.com/threads/T-01a212ec-680f-75c8-8e4a-84f218b3d9ed
Co-authored-by: Amp <amp@ampcode.com>
Parse GitHub Copilot's reasoning_text field
Merges charmbracelet/fantasy main at a00cb28 (v0.48.3 plus Copilot
reasoning for openaicompat, charmbracelet#459).

Conflict resolutions:
- providers/openai: take upstream's reasoning model check (charmbracelet#386), which
  replaces the fork's reasoningGenerationPattern (#57) and
  drops the service tier and auto truncation checks. Keep the fork's
  reasoning-model override on both transports (#57) and its
  include handling after the tools (#62).
- providers/anthropic: count cache tokens in TotalTokens (charmbracelet#457) on the
  fork's per-request usage (#50).
- providers/google: take upstream's tool result media (charmbracelet#463), which
  replaces the fork's (#58).
- go.mod, go.sum: take upstream's, keep the fork's SDK replaces. The
  next commit restores the coder SDK forks and Go 1.26.
coder/coder ships the coder forks of anthropic-sdk-go and openai-go and
builds with Go 1.26, so keep both after the upstream sync:

- Import github.com/openai/openai-go/v3 instead of
  github.com/charmbracelet/openai-go in the two files upstream added
  (request compression, charmbracelet#425, and the openrouter hook tests, charmbracelet#459).
- go.mod: go 1.26.5, and require the SDK modules the replaces point at
  the coder forks. Keep kronk v1.31.5, the last release that builds
  with Go 1.26, with its jinja v1.8.0 and yzma v1.23.0.
- go.mod: keep kaptinlin/jsonschema v0.9.8, as v0.9.10 (charmbracelet#441) needs
  Go 1.27.
- examples/go.mod: same Go and pins.
… token totals

- openai: an unknown model on the Responses API now counts as a
  reasoning model (charmbracelet#386), and gpt-40 is no longer a special case.
- anthropic: TotalTokens at Finish includes cache tokens (charmbracelet#457).
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T05:40:09.168404Z dc958ba Manual request
🔒 Security Review ✅ Completed 2026-12-01T05:27:24.500514Z dc958ba Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14a7aee78c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread providers/openai/language_model.go Resolved
Comment thread providers/openai/language_model.go Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 14a7aee78c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Go 1.26.10 has a net/http vulnerability that Go 1.26.11 fixes
(GO-2026-6859), so govulncheck fails on every PR.
The called charmbracelet/meta lint workflow declares checks: write and
pull-requests: read. The default token no longer carries them, so the
run stops at startup with "The workflow is requesting 'checks: write,
pull-requests: read', but is only allowed 'checks: none,
pull-requests: none'".
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

re: Stop after the consumer rejects the warning
re: Record receipt time separately for each streamed chunk

Both of these come from upstream, not from the sync: the flagged lines in providers/openai/language_model.go are identical to charmbracelet/fantasy main at a00cb28. The discarded warning yield is upstream's c8094fd (and 33015b8, which this branch already had before the sync). The first chunk receipt time is how upstream's 579e435 built ReceivedAt in all five stream implementations, and upstream's own TestStreamReceivedAtBeforeConsumerDelay asserts that every delta carries the first chunk's time. coder/coder only stops reading a stream on an error part and doesn't read ReceivedAt, so I'm leaving both as upstream has them rather than diverging the fork in a sync PR.

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: dc958ba380

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: dc958ba380

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ethanndickson
ethanndickson marked this pull request as ready for review December 1, 2026 05:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc958ba380

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread retry.go Resolved
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

re: Check cancellation before consulting RetryableError

This one is upstream's too: retry.go is identical to charmbracelet/fantasy main at a00cb28. The order is not new either. Before the sync a ProviderError was already asked first and the cancellation check came second, and upstream's b494fd1 only widened that first check to any RetryableError. coder/coder doesn't run fantasy's agent loop, which is the only caller of this retry, and defines no RetryableError.

Still declined from the earlier round, for the same reason (lines identical to upstream, and coder/coder doesn't reach them):

re: Stop after the consumer rejects the warning
re: Record receipt time separately for each streamed chunk

I'm leaving all three as upstream has them rather than diverging the fork in a sync PR.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: dc958ba380

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ethanndickson
ethanndickson merged commit 7f63731 into coder_2_33 Dec 1, 2026
6 checks passed
ethanndickson added a commit to coder/coder that referenced this pull request Dec 1, 2026
Bump the fantasy fork to its sync with upstream v0.48.3 (coder/fantasy#86),
whose Chat Completions reasoning check knows gpt-6 through gpt-9. Azure
OpenAI models now also obey the Reasoning Model setting, and the model
form shows it for them, as a deployment name does not have to say what
model it serves.

This replaces the earlier approach of routing Azure OpenAI through the
OpenAI client.
ethanndickson added a commit to coder/coder that referenced this pull request Dec 2, 2026
)

Closes #31714
Closes WI-31

Azure OpenAI reasoning models reject `max_tokens`:

```
Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.
```

We pick between `max_tokens` and `max_completion_tokens` from the model
name, and that check only knew names up to `gpt-5`, so a `gpt-6-luna`
deployment failed on default settings. To fix, the fantasy bump
(coder/fantasy#86, coder/fantasy#87 and coder/fantasy#88) extends the
check to `gpt-6` through `gpt-9`. That bump is a full sync with
upstream, so it also brings the other chatd changes listed there, which
is why a few test expectations move here.

On Azure that name is the deployment name though, which doesn't have to
say what model it serves. So the model form now also shows the existing
Reasoning Model setting for Azure models, and we obey it. With it on, we
send `max_completion_tokens` and drop `temperature` and `top_p`,
whatever the deployment is called.

I confirmed against a real Azure `gpt-5.4` deployment that it rejects
`max_tokens` and accepts `max_completion_tokens`, but that test resource
has since gone, so I haven't run this exact change against Azure.

This only fixes the `max_tokens` error. Going by [Microsoft's
docs](https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/reasoning),
I think GPT-6 chats on Azure will then hit a second error, as on Chat
Completions those models only accept tools with the reasoning effort set
to `none`, or not at all. The OpenAI and Bedrock providers use the
Responses API, so they aren't affected. I can't reproduce that for the
same reason, so it's being tracked separately at
[CODAGT-1655](https://linear.app/codercom/issue/CODAGT-1655).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants