Skip to content

Conversation

jaxxjj
Copy link

@jaxxjj jaxxjj commented Aug 5, 2025

What type of PR is this?

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

问题

Eino claude model 在处理 thinking 内容时有两个问题:

  1. 接收阶段的签名丢失
    在处理 claude 返回的 thinking block时,保存了内容但丢了signature:
// convOutputMessage
case anthropic.ThinkingBlock:
    setThinking(dstMsg, block.Thinking)       
    dstMsg.ReasoningContent = block.Thinking  
    // 没有 block.Signature

// convStreamEvent  
case anthropic.SignatureDelta:
    // 没有处理

这个会报 Invalid 'signature' in 'thinking' block

发送阶段的内容忽略
convSchemaMessage() 在重新发送回给 claude 时跳过了 thinking 相关处理:

func convSchemaMessage(message *schema.Message) {
    // 只处理常规文本
    if len(message.Content) > 0 {
        messageParams = append(messageParams, anthropic.NewTextBlock(message.Content))
    }
    // ReasoningContent (or eino claude thinking) 和signature没加上
}

这个会报Expected 'thinking' or 'redacted_thinking', but found 'text'

解决方案

  1. 添加sig处理

  2. convSchemaMessage() 正确重建完整的 thinking 块

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

@CLAassistant
Copy link

CLAassistant commented Aug 5, 2025

CLA assistant check
All committers have signed the CLA.

@mrh997
Copy link
Contributor

mrh997 commented Aug 19, 2025

  1. 看描述只有在需要发回 Thinking 时才需要将 Signature 一同发回,那更好的方式应该是加一个 CallOption ,比如 WithSendBackThinking()
image 2. 这个能力比较少人提,了解下 Claude 是会把 Thinking 也当做上下文处理吗

@jaxxjj jaxxjj force-pushed the fix/claude-thinking branch from 59b6a49 to 326e7e0 Compare August 20, 2025 08:24
@jaxxjj
Copy link
Author

jaxxjj commented Aug 20, 2025

  1. 看描述只有在需要发回 Thinking 时才需要将 Signature 一同发回,那更好的方式应该是加一个 CallOption ,比如 WithSendBackThinking()

image 2. 这个能力比较少人提,了解下 Claude 是会把 Thinking 也当做上下文处理吗

添加了 WithSendBackThinking 有工具调用必须包含 thinking
然后 claude 会把 thinking blocks 作为上下文处理 在tool使用时要保持推理连续性 然后对话的时候也是放在messages中作为context

@mrh997
Copy link
Contributor

mrh997 commented Aug 20, 2025

  1. 看描述只有在需要发回 Thinking 时才需要将 Signature 一同发回,那更好的方式应该是加一个 CallOption ,比如 WithSendBackThinking()

image 2. 这个能力比较少人提,了解下 Claude 是会把 Thinking 也当做上下文处理吗

添加了 WithSendBackThinking 有工具调用必须包含 thinking 然后 claude 会把 thinking blocks 作为上下文处理 在tool使用时要保持推理连续性 然后对话的时候也是放在messages中作为context

我又去看了下文档,这个 extended thinking 能力好像还蛮复杂的,我们细看后再接着讨论吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants