跳转到正文
入门
快速提示
10 分钟

快速提示:升级到 Claude Sonnet 4.6 以实现更快的智能体任务

Claude Sonnet 4.6 带来了更智能的智能体搜索——消耗更少的令牌、更低的延迟、相同的输出质量。在 10 分钟内升级你现有的项目。

1 章 2026 年 4 月更新于:2026 年 4 月 6 日

Sonnet 4.6 有什么变化?

Anthropic 的 Sonnet 4.6 版本(2026 年 4 月)聚焦于智能体效率——即模型在多步骤任务中如何搜索和检索信息。

更智能的上下文保留
在多步骤任务中将重复查找减少约 20-30%
分块结果选择
返回大文件中的相关部分,而不是整个文件
精确的查询构建
更精准的搜索查询 = 需要处理的无关结果更少

另一个新特性:Message Batches API 上限提高到每批 300,000 个令牌,适用于 Opus 4.6 和 Sonnet 4.6。

步骤 1:找到你的模型字符串

在你的代码库中,搜索当前的模型标识符。它通常位于以下位置之一:

# Search for model string in your project
# In terminal:
grep -r "claude-" src/ --include="*.ts" --include="*.tsx" --include="*.js"

# Common locations:
# - lib/ai.ts or lib/claude.ts
# - app/api/*/route.ts
# - services/llm.ts

你通常会找到类似 claude-sonnet-4-5claude-3-5-sonnet-20241022 的字符串。

步骤 2:更新到 Sonnet 4.6

将旧的模型字符串替换为 claude-sonnet-4-6

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();

const response = await client.messages.create({
  // Before: "claude-sonnet-4-5" or "claude-3-5-sonnet-20241022"
  model: "claude-sonnet-4-6", // ← Change this
  max_tokens: 4096,
  messages: [
    {
      role: "user",
      content: "Your prompt here"
    }
  ]
});
对于大多数用例,这样就足够了。
一旦切换到新模型,智能体搜索的改进就会自动生效。无需更改提示词。

附加:对大型任务使用 Message Batches API

如果你要处理许多文件或记录,Batches API 现在支持每批 300K 个令牌——非常适合批量代码审查或安全审计:

const client = new Anthropic();

// Process multiple files in parallel (up to 300K tokens total)
const batch = await client.messages.batches.create({
  requests: filesToReview.map((file) => ({
    custom_id: file.path,
    params: {
      model: "claude-sonnet-4-6",
      max_tokens: 1024,
      messages: [{
        role: "user",
        content: `Review this file for security issues:\n\n${file.content}`
      }]
    }
  }))
});

// Poll until complete
let result = batch;
while (result.processing_status === "in_progress") {
  await new Promise(r => setTimeout(r, 2000));
  result = await client.messages.batches.retrieve(batch.id);
}

// Collect results
for await (const item of client.messages.batches.results(batch.id)) {
  console.log(`${item.custom_id}: ${item.result.type}`);
}

小结

  • 将模型字符串改为 claude-sonnet-4-6
  • 智能体搜索的改进是自动的——无需更改提示词
  • 在多步骤智能体任务中,预计可减少约 20-30% 的冗余查找
  • Batches API 现在支持每批 300K 个令牌,用于并行处理