Skip to content

Commit 680038f

Browse files
committed
update README
1 parent 842ef3a commit 680038f

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,23 @@ Each layer has one job. No layer knows about the layers above it.
5555
## Quick Start
5656

5757
```bash
58-
# Install globally
58+
# Install
5959
go install github.com/voocel/codebot/cmd/codebot@latest
6060

61-
# Or build from source
61+
# Set API key and run
62+
export ANTHROPIC_API_KEY=sk-ant-...
63+
codebot
64+
```
65+
66+
Or build from source:
67+
68+
```bash
6269
git clone https://github.com/voocel/codebot.git
6370
cd codebot && go build -o codebot ./cmd/codebot
6471
```
6572

73+
Supported environment variables: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`. For more options see [settings.example.jsonc](settings.example.jsonc).
74+
6675
## Usage
6776

6877
```bash

README_zh.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,23 @@
5555
## 快速开始
5656

5757
```bash
58-
# 全局安装
58+
# 安装
5959
go install github.com/voocel/codebot/cmd/codebot@latest
6060

61-
# 或从源码构建
61+
# 设置 API Key 并运行
62+
export ANTHROPIC_API_KEY=sk-ant-...
63+
codebot
64+
```
65+
66+
或从源码构建:
67+
68+
```bash
6269
git clone https://github.com/voocel/codebot.git
6370
cd codebot && go build -o codebot ./cmd/codebot
6471
```
6572

73+
支持的环境变量:`ANTHROPIC_API_KEY``OPENAI_API_KEY``GEMINI_API_KEY`。更多配置项参考 [settings.example.jsonc](settings.example.jsonc)
74+
6675
## 使用
6776

6877
```bash

internal/agent/session.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package agent
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"strings"
67
"sync"
@@ -743,9 +744,17 @@ func (s *Session) persistMessage(msg agentcore.Message) {
743744
s.mu.Unlock()
744745
if store != nil {
745746
if err := store.AppendMessage(msg); err != nil {
747+
// Enrich error with tool call details for diagnosis.
748+
detail := err.Error()
749+
for _, tc := range msg.ToolCalls() {
750+
if !json.Valid(tc.Args) {
751+
detail = fmt.Sprintf("%s [invalid args in %s(%s): %s]",
752+
detail, tc.Name, tc.ID, truncateBytes(tc.Args, 200))
753+
}
754+
}
746755
s.emit(SessionEvent{
747756
Type: SEError,
748-
Error: fmt.Errorf("persist message: %w", err),
757+
Error: fmt.Errorf("persist message: %s", detail),
749758
})
750759
}
751760
}
@@ -763,6 +772,14 @@ func (s *Session) flushPendingMessages() {
763772
}
764773
}
765774

775+
// truncateBytes returns at most n bytes from b, appending "..." if truncated.
776+
func truncateBytes(b []byte, n int) string {
777+
if len(b) <= n {
778+
return string(b)
779+
}
780+
return string(b[:n]) + "..."
781+
}
782+
766783
// reclampThinking re-clamps the current thinking level to the new model's capabilities.
767784
func (s *Session) reclampThinking() {
768785
if s.registry == nil {

0 commit comments

Comments
 (0)