Skip to content

Commit ba363b9

Browse files
committed
style: fix lint issues - line length, imports, and end-of-file newlines
1 parent 625f5ef commit ba363b9

11 files changed

Lines changed: 43 additions & 18 deletions

File tree

backend/app/agent/agent_model.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
from camel.toolkits import FunctionTool, RegisteredAgentToolkit
2222
from camel.types import ModelPlatformType
2323

24-
from app.utils.event_loop_utils import _schedule_async_task
2524
from app.agent.listen_chat_agent import ListenChatAgent, logger
2625
from app.model.chat import AgentModelConfig, Chat
2726
from app.service.task import ActionCreateAgentData, Agents, get_task_lock
27+
from app.utils.event_loop_utils import _schedule_async_task
2828

2929

3030
def agent_model(
@@ -64,8 +64,9 @@ def agent_model(
6464

6565
if custom_model_config and custom_model_config.has_custom_config():
6666
for attr in config_attrs:
67-
effective_config[attr] = getattr(custom_model_config, attr,
68-
None) or getattr(options, attr)
67+
effective_config[attr] = getattr(
68+
custom_model_config, attr, None
69+
) or getattr(options, attr)
6970
extra_params = (
7071
custom_model_config.extra_params or options.extra_params or {}
7172
)

backend/app/agent/listen_chat_agent.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from camel.types.agents import ToolCallingRecord
3535
from pydantic import BaseModel
3636

37-
from app.utils.event_loop_utils import _schedule_async_task
3837
from app.service.task import (
3938
Action,
4039
ActionActivateAgentData,
@@ -45,6 +44,7 @@
4544
get_task_lock,
4645
set_process_task,
4746
)
47+
from app.utils.event_loop_utils import _schedule_async_task
4848

4949
# Logger for agent tracking
5050
logger = logging.getLogger("agent")
@@ -162,7 +162,7 @@ def _extract_tokens(response) -> int:
162162
return usage_info.get("total_tokens", 0)
163163

164164
def _stream_chunks(self, response_gen):
165-
"""Generator that wraps a streaming response and sends chunks to frontend.
165+
"""Generator wrapping streaming response for frontend.
166166
167167
Args:
168168
response_gen: The original streaming response generator
@@ -171,7 +171,7 @@ def _stream_chunks(self, response_gen):
171171
Each chunk from the original generator
172172
173173
Returns:
174-
Tuple of (accumulated_content, total_tokens) via StopIteration value
174+
Tuple of (accumulated_content, total_tokens) via StopIteration
175175
"""
176176
accumulated_content = ""
177177
last_chunk = None
@@ -187,7 +187,7 @@ def _stream_chunks(self, response_gen):
187187
self._send_agent_deactivate(accumulated_content, total_tokens)
188188

189189
async def _astream_chunks(self, response_gen):
190-
"""Async generator that wraps a streaming response and sends chunks to frontend.
190+
"""Async generator wrapping streaming response for frontend.
191191
192192
Args:
193193
response_gen: The original async streaming response generator
@@ -546,7 +546,7 @@ async def _aexecute_tool(
546546
if hasattr(tool, "_toolkit_name"):
547547
toolkit_name = tool._toolkit_name
548548

549-
# Method 2: For MCP tools, check if func has __self__ (the toolkit instance)
549+
# Method 2: For MCP tools, check if func has __self__
550550
if (
551551
not toolkit_name
552552
and hasattr(tool, "func")
@@ -602,7 +602,7 @@ async def _aexecute_tool(
602602
# Try different invocation paths in order of preference
603603
if hasattr(tool, "func") and hasattr(tool.func, "async_call"):
604604
# Case: FunctionTool wrapping an MCP tool
605-
# Check if the wrapped tool is sync to avoid run_in_executor
605+
# Check if wrapped tool is sync to avoid executor
606606
if hasattr(tool, "is_async") and not tool.is_async:
607607
# Sync tool: call directly to preserve ContextVar
608608
result = tool(**args)
@@ -620,7 +620,7 @@ async def _aexecute_tool(
620620
# Sync tool: call directly to preserve ContextVar
621621
# in same thread
622622
result = tool(**args)
623-
# Handle case where synchronous call returns a coroutine
623+
# Handle sync call returning a coroutine
624624
if asyncio.iscoroutine(result):
625625
result = await result
626626
else:
@@ -638,7 +638,7 @@ async def _aexecute_tool(
638638
result = await tool(**args)
639639

640640
else:
641-
# Fallback: synchronous call - call directly in current context
641+
# Fallback: sync call directly in current context
642642
# DO NOT use run_in_executor to preserve ContextVar
643643
result = tool(**args)
644644
# Handle case where synchronous call returns a coroutine
@@ -713,7 +713,9 @@ def clone(self, with_memory: bool = False) -> ChatAgent:
713713
schema for schema in self._external_tool_schemas.values()
714714
],
715715
response_terminators=self.response_terminators,
716-
scheduling_strategy=self.model_backend.scheduling_strategy.__name__,
716+
scheduling_strategy=(
717+
self.model_backend.scheduling_strategy.__name__
718+
),
717719
max_iteration=self.max_iteration,
718720
stop_event=self.stop_event,
719721
tool_execution_timeout=self.tool_execution_timeout,

backend/app/agent/tools.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,22 @@ async def get_toolkits(tools: list[str], agent_name: str, api_task_id: str):
8181
if item in toolkits:
8282
toolkit: AbstractToolkit = toolkits[item]
8383
toolkit.agent_name = agent_name
84-
toolkit_tools = toolkit.get_can_use_tools(api_task_id)
85-
toolkit_tools = await toolkit_tools if asyncio.iscoroutine(
86-
toolkit_tools
87-
) else toolkit_tools
84+
85+
# Handle RAGToolkit with task-specific isolation
86+
# Task isolation via collection_name; shared storage path
87+
if item == "rag_toolkit":
88+
toolkit_tools = toolkit.get_can_use_tools(
89+
api_task_id=api_task_id,
90+
collection_name=get_task_collection_name(api_task_id),
91+
)
92+
else:
93+
toolkit_tools = toolkit.get_can_use_tools(api_task_id)
94+
95+
toolkit_tools = (
96+
await toolkit_tools
97+
if asyncio.iscoroutine(toolkit_tools)
98+
else toolkit_tools
99+
)
88100
res.extend(toolkit_tools)
89101
else:
90102
logger.warning(f"Toolkit {item} not found for agent {agent_name}")
@@ -124,8 +136,10 @@ async def get_mcp_tools(mcp_server: McpServers):
124136
tool_names = [
125137
(
126138
tool.get_function_name()
127-
if hasattr(tool, "get_function_name") else str(tool)
128-
) for tool in tools
139+
if hasattr(tool, "get_function_name")
140+
else str(tool)
141+
)
142+
for tool in tools
129143
]
130144
logging.debug(f"MCP tool names: {tool_names}")
131145
return tools

backend/app/component/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
# limitations under the License.
1313
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
1414

15+

backend/app/component/pydantic/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
# limitations under the License.
1313
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
1414

15+

backend/app/exception/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
# limitations under the License.
1313
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
1414

15+

backend/app/model/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
# limitations under the License.
1313
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
1414

15+

backend/app/service/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
# limitations under the License.
1313
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
1414

15+

backend/app/utils/listen/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
# limitations under the License.
1313
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
1414

15+

backend/app/utils/server/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
# limitations under the License.
1313
# ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
1414

15+

0 commit comments

Comments
 (0)