| 15 | text: str = '' |
| 16 | |
| 17 | class ToolResultContentBlock(ContentBlock): |
| 18 | type: Literal['tool_result'] = 'tool_result' |
| 19 | id: str |
| 20 | name: str = '' |
| 21 | output: str = '' |
| 22 | is_error: Optional[bool] = None |
| 23 | |
| 24 | # Discriminated Union: Pydantic 根据 type 字段自动选正确的子类反序列化 |
| 25 | # 没有这个,model_validate() 只会创建基类 ContentBlock,丢失 text/name 等字段。 |