Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.

fix: reset token state on /new and support DeepSeek reasoning_effort - #524

Merged
Chronostasys merged 4 commits into
masterfrom
fix/new-token-reset-and-deepseek-effort
Apr 26, 2026
Merged

Chronostasys merged 4 commits into
masterfrom
fix/new-token-reset-and-deepseek-effort

Conversation

@Chronostasys

Copy link
Copy Markdown
Collaborator

Bug Fix: /new 后上下文进度条没重置

根因: handleNewSession 清空了消息和记忆,但没有清理 DB 中的 token state (SetTokenState(0,0)),也没有通知 CLI 端清除 lastTokenUsage。下次 Run() 恢复了旧 token 数据,进度条显示上一轮的值。

修复:

  1. handleNewSession 中调用 SetTokenState(0,0) 清 DB token state
  2. /new 回复通过 Metadata["session_reset"] 通知客户端
  3. CLI handleAgentMessage 检测 session_reset 后清除 lastTokenUsage 和 context bar 缓存
  4. Remote mode: wsMessage/wsIncomingMessage 新增 SessionReset 字段通过 WS 传递

Feature: DeepSeek reasoning_effort 参数支持

根据 DeepSeek 思考模式文档,工具调用场景支持 reasoning_effort 参数控制思考强度。

实现:

  • buildThinkingOptions 支持三种 JSON 格式:
    1. Flat thinking object: {"type":"enabled"}
    2. Nested with extras: {"thinking":{"type":"enabled"},"reasoning_effort":"high"}
    3. Arbitrary key-values: {"reasoning_effort":"high"}
  • reasoning_content 回传逻辑已正确处理(无需改动)
  • 更新 /set-llm usage 文档

示例:

/set-llm provider=deepseek base_url=https://api.deepseek.com/v1 api_key=sk-xxx model=deepseek-reasoner thinking_mode={"thinking":{"type":"enabled"},"reasoning_effort":"high"}

测试

  • ✅ go build ./...
  • ✅ go test ./... (all packages pass)
  • ✅ Pre-push hooks passed (vet + build + test)

Bug fix:
- /new command now clears DB token state (SetTokenState(0,0)) so the
  context usage bar resets instead of showing stale values from the
  previous session
- Agent sends session_reset metadata in the /new response
- CLI clears lastTokenUsage and context bar cache when it detects
  session_reset metadata (works in both local and remote modes)
- Remote mode: wsMessage and wsIncomingMessage carry session_reset
  field through WebSocket

Feature:
- OpenAI-compatible LLM provider now supports DeepSeek reasoning_effort
  parameter via thinking_mode JSON config:
  {"thinking":{"type":"enabled"},"reasoning_effort":"high"}
- buildThinkingOptions handles three JSON formats:
  1. Flat thinking object: {"type":"enabled"}
  2. Nested with extras: {"thinking":{...},"reasoning_effort":"high"}
  3. Arbitrary key-values: {"reasoning_effort":"high"}
- Updated /set-llm usage documentation with DeepSeek reasoning_effort
  example

Refs: https://api-docs.deepseek.com/zh-cn/guides/thinking_mode
Update all URLs referencing the old repository to the new home at
github.com/ai-pivot/xbot:

- Install scripts (install.sh, install.ps1): REPO variable
- Update check (version/check.go): primary URL → ai-pivot/xbot,
  with fallback to CjiW/xbot during transition period
- i18n update messages: curl install URLs
- CLI help text: install hint URL
- fetch.go: User-Agent header URL
- README.md: install commands and git clone URL
- docs-site: installation page, index, hugo.toml repo link

The version checker tries the new repo first. If no releases exist yet
on ai-pivot/xbot, it falls back to CjiW/xbot so existing users continue
to receive update notifications during the migration.
Install scripts now try ai-pivot/xbot first, and fall back to
CjiW/xbot if the release is not found (404). This keeps CI passing
while the new repo has no releases yet.

Applies to:
- install.sh: resolve_version, binary download, web dist, checksums
- install.ps1: Get-LatestVersion, binary download, checksums
@Chronostasys
Chronostasys force-pushed the fix/new-token-reset-and-deepseek-effort branch from 6ad385d to add61ac Compare April 26, 2026 12:45
…ting

Add 'DeepSeek: effort=high' and 'DeepSeek: effort=max' options to the
Thinking Mode selector in TUI Settings panel (all 3 locales: zh/en/ja).

These encode reasoning_effort into the thinking_mode JSON value so no
DB schema change is needed.
@Chronostasys
Chronostasys merged commit c5f05f5 into master Apr 26, 2026
16 checks passed
@Chronostasys
Chronostasys deleted the fix/new-token-reset-and-deepseek-effort branch April 26, 2026 16:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant