feat(ai): modernize the Anthropic path and fix conversation replay - #663
Open
yupanzi wants to merge 1 commit into
Open
feat(ai): modernize the Anthropic path and fix conversation replay#663yupanzi wants to merge 1 commit into
yupanzi wants to merge 1 commit into
Conversation
Update the Claude integration to the current API surface and fix several agent-loop bugs: - Move the Anthropic path to the Beta Messages API with adaptive thinking, context management, and output_config.effort. Effort is the reasoning-depth knob on current Claude models (budget_tokens returns 400 there); it is exposed as a new AIEffort setting (low/medium/high/xhigh/max, default xhigh) in the general settings. Feature use is gated per model so older models keep the classic request shape. - Send AIMaxTokens as configured and make the default provider-aware (64000 for Anthropic, 8192 for OpenAI): on current Claude models thinking and answer share max_tokens, so the old 4096 default truncated answers mid-sentence. Default Anthropic model is now claude-opus-5. - Replay tool turns structurally instead of flattening them to "[Tool: ...]" text. Textual replay poisoned the model into emitting tool calls as plain text/XML on later turns; the frontend now sends the tool round-trip (id, name, args, result) and the backend rebuilds real tool_use/tool_result blocks. - Mask Secret data in tool results before they reach the model. - Emit an SSE keepalive comment every 20s: an agent turn is legitimately silent while a tool runs, and ingress-nginx closes the connection after 60s of backend silence. Raise the chart's gateway request timeout to 900s and document the matching ingress-nginx annotations next to it. - Tighten resource tool schemas/descriptions with explicit caps, and fix long-token overflow in AI chat markdown tables. - Cover conversation replay, handler streaming, settings migration, and the agent loop with tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Modernize the Anthropic path and fix conversation replay:
Anthropic request surface
output_config.effort. Feature use is gated per model (anthropicModelSupportsModernFeatures) so models that reject the modern surface keep the classic request shape.low/medium/high/xhigh/max, defaultxhigh), exposed in general settings next to Max Tokens, with hints explaining both knobs.AIMaxTokensis sent as configured (never clamped) and the default is provider-aware: 64000 for Anthropic, 8192 for OpenAI. Existing installs with the old 4096 default are migrated (covered bygeneral_setting_upgrade_test.go). Default Anthropic model bumped toclaude-opus-5.Conversation replay
role: toolwith id/name/args/result) and the backend rebuilds realtool_use/tool_resultblocks. Tool messages without a result (denied/cancelled) are skipped so no danglingtool_useis produced. Covered byconversation_history_test.go.Robustness
values.yaml— these are two halves of the same fix.Why
The Anthropic integration predates the current Claude API surface:
budget_tokensnow returns 400 on current models, the 4096-token default truncates answers (thinking and answer sharemax_tokens), and tool turns were replayed to the model as flattened[Tool: ...]text, which poisons later turns into emitting tool calls as plain text/XML instead of native tool use. Long agent turns also died behind ingress-nginx, which closes a connection after 60s of backend silence while a tool is legitimately still running.Related issue
Closes #668
Validation
go test ./pkg/ai/... ./pkg/model/... ./pkg/settings/...(new: conversation history, handler streaming, settings migration tests)pnpm run type-check && pnpm run lint && pnpm run testhelm lint+helm templatefor the chart changeChecklist
🤖 Generated with Claude Code