Skip to content

Commit 18b3d15

Browse files
GenerQAQclaude
andauthored
fix(core): add "thinking" to Part.type Literal to match Go API schema (#402)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 30d6318 commit 18b3d15

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

src/server/core/acontext_core/schema/orm/message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class Part(BaseModel):
3737
"""Message part model matching the GORM Part struct"""
3838

3939
type: Literal[
40-
"text", "image", "audio", "video", "file", "tool-call", "tool-result", "data"
41-
] # "text" | "image" | "audio" | "video" | "file" | "tool-call" | "tool-result" | "data"
40+
"text", "image", "audio", "video", "file", "tool-call", "tool-result", "data", "thinking"
41+
] # "text" | "image" | "audio" | "video" | "file" | "tool-call" | "tool-result" | "data" | "thinking"
4242

4343
# text part
4444
text: Optional[str] = None
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import pytest
2+
from pydantic import ValidationError
3+
from acontext_core.schema.orm.message import Part
4+
5+
6+
VALID_PART_TYPES = [
7+
"text",
8+
"image",
9+
"audio",
10+
"video",
11+
"file",
12+
"tool-call",
13+
"tool-result",
14+
"data",
15+
"thinking",
16+
]
17+
18+
19+
@pytest.mark.parametrize("part_type", VALID_PART_TYPES)
20+
def test_part_accepts_valid_types(part_type):
21+
part = Part(type=part_type)
22+
assert part.type == part_type
23+
24+
25+
def test_part_rejects_invalid_type():
26+
with pytest.raises(ValidationError):
27+
Part(type="unknown")
28+
29+
30+
def test_thinking_part_with_signature():
31+
part = Part(
32+
type="thinking",
33+
text="Let me think about this.",
34+
meta={"signature": "abc123"},
35+
)
36+
assert part.type == "thinking"
37+
assert part.text == "Let me think about this."
38+
assert part.meta["signature"] == "abc123"
39+
40+
41+
def test_thinking_part_minimal():
42+
part = Part(type="thinking", text="thinking text")
43+
assert part.type == "thinking"
44+
assert part.meta is None

0 commit comments

Comments
 (0)