Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-memes-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@langchain/anthropic": patch
---

fix sonnet-4.5 thinking
2 changes: 1 addition & 1 deletion libs/langchain-anthropic/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ export class ChatAnthropicMessages<
throw new Error("topK is not supported when thinking is enabled");
}
if (
this.model.includes("opus-4-1")
this.model.includes("opus-4-1") || this.model.includes("sonnet-4-5")
? this.topP !== undefined
: this.topP !== -1
) {
Expand Down
16 changes: 16 additions & 0 deletions libs/langchain-anthropic/src/tests/chat_models.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1503,4 +1503,20 @@ describe("Sonnet 4.5", () => {
);
expect(response.content.length).toBeGreaterThan(0);
});

it("works with streaming and thinking", async () => {
const model = new ChatAnthropic({
model: "claude-sonnet-4-5-20250929",
thinking: {
type: "enabled",
budget_tokens: 1024,
},
});

const response = await model.invoke(
"Please respond to this message simply with: Hello"
);

expect(response.content.length).toBeGreaterThan(0);
});
});
Loading