feat: release 1.1.0 with responsive task control
This commit is contained in:
1 parent
057f0c3050
commit
bfcd828fa8
37 files changed
+1601
-151
No files matched your search
@@ -18,7 +18,7 @@ from pathlib import Path
|
||||
from typing import Annotated, Any
|
||||
from langchain_core.messages import HumanMessage, SystemMessage, ToolMessage
|
||||
from langchain_core.tools import BaseTool, StructuredTool
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, ValidationError
|
||||
|
||||
|
||||
class _CyFunctionDetectorMeta(type):
|
||||
@@ -89,6 +89,20 @@ class LogAnalyzerNode:
|
||||
original_coroutine = tool.coroutine
|
||||
|
||||
async def cached_coroutine(**kwargs):
|
||||
# The injection runner calls the coroutine directly, bypassing
|
||||
# StructuredTool's normal Pydantic argument coercion. Normalize
|
||||
# model-supplied numeric strings before caching or searching logs.
|
||||
if tool.name in ("read_logs", "search_logs") and tool.args_schema:
|
||||
try:
|
||||
validated = tool.args_schema.model_validate(kwargs)
|
||||
except ValidationError as exc:
|
||||
return ToolFailure(f"Invalid {tool.name} arguments: {exc}")
|
||||
kwargs.update(validated.model_dump(exclude_unset=True))
|
||||
if kwargs.get("lines") is None:
|
||||
kwargs["lines"] = 200 if tool.name == "read_logs" else 10000
|
||||
if tool.name == "search_logs" and kwargs.get("context_lines") is None:
|
||||
kwargs["context_lines"] = 0
|
||||
|
||||
if tool.name == "read_logs":
|
||||
# Intercept read_logs to cache raw logs
|
||||
lines = kwargs.get("lines", 200)
|
||||
|
||||
Reference in new issue
Block a user