Skip to content

Commit 1d1d4d4

Browse files
committed
chore(app): fix typing for most cases
1 parent 5f3358c commit 1d1d4d4

17 files changed

Lines changed: 45 additions & 36 deletions

app/agent/browser.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ class BrowserAgent(ToolCallAgent):
1818
extract content, and perform other browser-based actions to accomplish tasks.
1919
"""
2020

21-
name = "browser"
22-
description = "A browser agent that can control a browser to accomplish tasks"
21+
name: str = "browser"
22+
description: str | None = (
23+
"A browser agent that can control a browser to accomplish tasks"
24+
)
2325

24-
system_prompt = SYSTEM_PROMPT
25-
next_step_prompt = NEXT_STEP_PROMPT
26+
system_prompt: str | None = SYSTEM_PROMPT
27+
next_step_prompt: str | None = NEXT_STEP_PROMPT
2628

27-
max_observe = 10000
28-
max_steps = 20
29+
max_observe: int | None = 10000
30+
max_steps: int = 20
2931

3032
# Configure the available tools
3133
available_tools: ToolCollection = Field(

app/agent/manus.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class Manus(BrowserAgent):
2020
"""
2121

2222
name: str = "Manus"
23-
description: str = (
23+
description: str | None = (
2424
"A versatile agent that can solve various tasks using multiple tools"
2525
)
2626

27-
system_prompt: str = SYSTEM_PROMPT.format(directory=config.workspace_root)
28-
next_step_prompt: str = NEXT_STEP_PROMPT
27+
system_prompt: str | None = SYSTEM_PROMPT.format(directory=config.workspace_root)
28+
next_step_prompt: str | None = NEXT_STEP_PROMPT
2929

30-
max_observe: int = 10000
30+
max_observe: int | None = 10000
3131
max_steps: int = 20
3232

3333
# Add general-purpose tools to the tool collection

app/agent/planning.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class PlanningAgent(ToolCallAgent):
1919
"""
2020

2121
name: str = "planning"
22-
description: str = "An agent that creates and manages plans to solve tasks"
22+
description: str | None = "An agent that creates and manages plans to solve tasks"
2323

24-
system_prompt: str = PLANNING_SYSTEM_PROMPT
25-
next_step_prompt: str = NEXT_STEP_PROMPT
24+
system_prompt: str | None = PLANNING_SYSTEM_PROMPT
25+
next_step_prompt: str | None = NEXT_STEP_PROMPT
2626

2727
available_tools: ToolCollection = Field(
2828
default_factory=lambda: ToolCollection(PlanningTool(), Terminate())
@@ -58,6 +58,7 @@ async def think(self) -> bool:
5858
if self.active_plan_id
5959
else self.next_step_prompt
6060
)
61+
assert prompt is not None, "next_step_prompt is not set"
6162
self.messages.append(Message.user_message(prompt))
6263

6364
# Get the current step index before thinking
@@ -210,6 +211,7 @@ async def create_initial_plan(self, request: str) -> None:
210211
)
211212
]
212213
self.memory.add_messages(messages)
214+
assert self.system_prompt is not None, "system_prompt is not set"
213215
response = await self.llm.ask_tool(
214216
messages=list(messages),
215217
system_msgs=[Message.system_message(self.system_prompt)],

app/agent/swe.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class SWEAgent(ToolCallAgent):
99
"""An agent that implements the SWEAgent paradigm for executing code and natural conversations."""
1010

1111
name: str = "swe"
12-
description: str = "an autonomous AI programmer that interacts directly with the computer to solve tasks."
12+
description: str | None = "an autonomous AI programmer that interacts directly with the computer to solve tasks."
1313

14-
system_prompt: str = SYSTEM_PROMPT
15-
next_step_prompt: str = NEXT_STEP_TEMPLATE
14+
system_prompt: str | None = SYSTEM_PROMPT
15+
next_step_prompt: str | None = NEXT_STEP_TEMPLATE
1616

1717
available_tools: ToolCollection = ToolCollection(
1818
Bash(), StrReplaceEditor(), Terminate()
@@ -28,6 +28,7 @@ async def think(self) -> bool:
2828
"""Process current state and decide next action"""
2929
# Update working directory
3030
self.working_dir = (await self.bash.execute("pwd")).output.strip()
31+
assert self.next_step_prompt is not None, "next_step_prompt is not set"
3132
self.next_step_prompt = self.next_step_prompt.format(
3233
current_dir=self.working_dir
3334
)

app/agent/toolcall.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
class ToolCallAgent(ReActAgent):
2323
"""Base agent class for handling tool/function calls with enhanced abstraction"""
2424

25-
name = "toolcall"
26-
description = "an agent that can execute tool calls."
25+
name: str = "toolcall"
26+
description: str | None = "an agent that can execute tool calls."
2727

28-
system_prompt = SYSTEM_PROMPT
29-
next_step_prompt = NEXT_STEP_PROMPT
28+
system_prompt: str | None = SYSTEM_PROMPT
29+
next_step_prompt: str | None = NEXT_STEP_PROMPT
3030

3131
available_tools: ToolCollection = ToolCollection(
3232
CreateChatCompletion(), Terminate()

app/tool/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class BaseTool(ABC, BaseModel):
88
name: str
99
description: str
10-
parameters: dict | None = None
10+
parameters: dict = Field(default_factory=dict)
1111

1212
class Config:
1313
arbitrary_types_allowed = True

app/tool/bash.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class Bash(BaseTool):
117117

118118
name: str = "bash"
119119
description: str = _BASH_DESCRIPTION
120-
parameters = {
120+
parameters: dict = {
121121
"type": "object",
122122
"properties": {
123123
"command": {

app/tool/browser_use_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
class BrowserUseTool(BaseTool, Generic[Context]):
5353
name: str = "browser_use"
5454
description: str = _BROWSER_DESCRIPTION
55-
parameters = {
55+
parameters: dict = {
5656
"type": "object",
5757
"properties": {
5858
"action": {

app/tool/create_chat_completion.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from types import NoneType
2-
from typing import Any, Type, Union, get_args, get_origin
2+
from typing import Any, Type, Union, cast, get_args, get_origin
33

44
from pydantic import BaseModel, Field
55

@@ -26,6 +26,7 @@ class CreateChatCompletion(BaseTool):
2626

2727
def __init__(self, response_type: Type | None = str):
2828
"""Initialize with a specific response type."""
29+
cast(Any, super().__init__)()
2930
self.response_type = response_type
3031
self.parameters = self._build_parameters()
3132

app/tool/file_saver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FileSaver(BaseTool):
1616
Use this tool when you need to save text, code, or generated content to a file on the local filesystem.
1717
The tool accepts content and a file path, and saves the content to that location.
1818
"""
19-
parameters = {
19+
parameters: dict = {
2020
"type": "object",
2121
"properties": {
2222
"content": {

0 commit comments

Comments
 (0)