Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</a>
</p>

LangChain is a framework for building agents and LLM-powered applications. It helps you chain together interoperable components and third-party integrations to simplify AI application development — all while future-proofing decisions as the underlying technology evolves.
LangChain is a framework for building agents and LLM-powered applications. It helps you chain together interoperable components and third-party integrations to simplify AI application development — all while future-proofing decisions as the underlying technology evolves.

```bash
pip install langchain
Expand Down
8 changes: 5 additions & 3 deletions libs/langchain_v1/langchain/agents/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,15 +1424,17 @@
def _fetch_last_ai_and_tool_messages(
messages: list[AnyMessage],
) -> tuple[AIMessage, list[ToolMessage]]:
last_ai_index: int
last_ai_message: AIMessage

last_ai_index: int | None = None
last_ai_message: AIMessage | None = None
for i in range(len(messages) - 1, -1, -1):
if isinstance(messages[i], AIMessage):
last_ai_index = i
last_ai_message = cast("AIMessage", messages[i])
break

if last_ai_message is None or last_ai_index is None:
raise ValueError("No AIMessage found in messages list")

Check failure on line 1436 in libs/langchain_v1/langchain/agents/factory.py

View workflow job for this annotation

GitHub Actions / lint (libs/langchain_v1, 3.10) / Python 3.10

Ruff (EM101)

langchain/agents/factory.py:1436:26: EM101 Exception must not use a string literal, assign to variable first

Check failure on line 1436 in libs/langchain_v1/langchain/agents/factory.py

View workflow job for this annotation

GitHub Actions / lint (libs/langchain_v1, 3.10) / Python 3.10

Ruff (TRY003)

langchain/agents/factory.py:1436:15: TRY003 Avoid specifying long messages outside the exception class

Check failure on line 1436 in libs/langchain_v1/langchain/agents/factory.py

View workflow job for this annotation

GitHub Actions / lint (libs/langchain_v1, 3.14) / Python 3.14

Ruff (EM101)

langchain/agents/factory.py:1436:26: EM101 Exception must not use a string literal, assign to variable first

Check failure on line 1436 in libs/langchain_v1/langchain/agents/factory.py

View workflow job for this annotation

GitHub Actions / lint (libs/langchain_v1, 3.14) / Python 3.14

Ruff (TRY003)

langchain/agents/factory.py:1436:15: TRY003 Avoid specifying long messages outside the exception class

tool_messages = [m for m in messages[last_ai_index + 1 :] if isinstance(m, ToolMessage)]
return last_ai_message, tool_messages

Expand Down
Loading