Skip to content

Commit c8b39f3

Browse files
committed
cope with warnings
1 parent 5b4b29f commit c8b39f3

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

template_langgraph/agents/demo_agents/deep_agent_core/state.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from typing import Annotated, Literal, NotRequired
1+
from typing import Annotated, Literal
22

33
from langgraph.prebuilt.chat_agent_executor import AgentState
4-
from typing_extensions import TypedDict
4+
from typing_extensions import NotRequired, TypedDict
55

66

77
class Todo(TypedDict):

template_langgraph/agents/demo_agents/deep_agent_core/sub_agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from typing import Annotated, Any, NotRequired
1+
from typing import Annotated, Any
22

33
from langchain.chat_models import init_chat_model
44
from langchain_core.messages import ToolMessage
55
from langchain_core.tools import BaseTool, InjectedToolCallId, tool
66
from langgraph.prebuilt import InjectedState, create_react_agent
77
from langgraph.types import Command
8-
from typing_extensions import TypedDict
8+
from typing_extensions import NotRequired, TypedDict
99

1010
from template_langgraph.agents.demo_agents.deep_agent_core.prompts import (
1111
TASK_DESCRIPTION_PREFIX,

template_langgraph/agents/demo_agents/deep_agent_core/tools.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,53 @@ def edit_file(
105105
mock_filesystem = state.get("files", {})
106106
# Check if file exists in mock filesystem
107107
if file_path not in mock_filesystem:
108-
return f"Error: File '{file_path}' not found"
108+
return Command(
109+
update={
110+
"messages": [ToolMessage(f"Error: File '{file_path}' not found", tool_call_id=tool_call_id)],
111+
}
112+
)
109113

110114
# Get current file content
111115
content = mock_filesystem[file_path]
112116

113117
# Check if old_string exists in the file
114118
if old_string not in content:
115-
return f"Error: String not found in file: '{old_string}'"
119+
return Command(
120+
update={
121+
"messages": [
122+
ToolMessage(
123+
f"Error: String not found in file: '{old_string}'",
124+
tool_call_id=tool_call_id,
125+
)
126+
],
127+
}
128+
)
116129

117130
# If not replace_all, check for uniqueness
118131
if not replace_all:
119132
occurrences = content.count(old_string)
120133
if occurrences > 1:
121-
return f"Error: String '{old_string}' appears {occurrences} times in file. Use replace_all=True to replace all instances, or provide a more specific string with surrounding context."
134+
return Command(
135+
update={
136+
"messages": [
137+
ToolMessage(
138+
f"Error: String '{old_string}' appears {occurrences} times in file. Use replace_all=True to replace all instances, or provide a more specific string with surrounding context.",
139+
tool_call_id=tool_call_id,
140+
)
141+
]
142+
}
143+
)
122144
elif occurrences == 0:
123-
return f"Error: String not found in file: '{old_string}'"
145+
return Command(
146+
update={
147+
"messages": [
148+
ToolMessage(
149+
f"Error: String not found in file: '{old_string}'",
150+
tool_call_id=tool_call_id,
151+
)
152+
],
153+
}
154+
)
124155

125156
# Perform the replacement
126157
if replace_all:

0 commit comments

Comments
 (0)