chore: apply pre-commit auto-fixes (trim trailing whitespace, EOF)
This commit is contained in:
@@ -192,9 +192,7 @@ class Agent:
|
||||
if cache_key_value is not None:
|
||||
cached = memory.stm.tool_results.get(tool_name, cache_key_value)
|
||||
if cached is not None:
|
||||
logger.info(
|
||||
f"Tool cache HIT: {tool_name}[{cache_key_value}]"
|
||||
)
|
||||
logger.info(f"Tool cache HIT: {tool_name}[{cache_key_value}]")
|
||||
self._post_tool_side_effects(tool_name, args, cached, from_cache=True)
|
||||
return {**cached, "_from_cache": True}
|
||||
|
||||
|
||||
@@ -165,7 +165,9 @@ EXPRESSIONS À UTILISER (une par situation, naturellement intégrées dans ta r
|
||||
lines.append(" Steps:")
|
||||
for step in steps:
|
||||
step_id = step.get("id", "?")
|
||||
step_tool = step.get("tool") or ("ask_user" if step.get("ask_user") else "—")
|
||||
step_tool = step.get("tool") or (
|
||||
"ask_user" if step.get("ask_user") else "—"
|
||||
)
|
||||
lines.append(f" - {step_id} ({step_tool})")
|
||||
lines.append(" Call end_workflow(reason) when done, cancelled, or off-topic.")
|
||||
return "\n".join(lines)
|
||||
|
||||
+15
-10
@@ -27,9 +27,9 @@ class ToolSpecError(ValueError):
|
||||
class ParameterSpec:
|
||||
"""Semantic description of a single tool parameter."""
|
||||
|
||||
description: str # Short: what the value represents.
|
||||
why_needed: str # Why the tool needs this — drives LLM reasoning.
|
||||
example: str | None = None # Concrete example value, shown to the LLM.
|
||||
description: str # Short: what the value represents.
|
||||
why_needed: str # Why the tool needs this — drives LLM reasoning.
|
||||
example: str | None = None # Concrete example value, shown to the LLM.
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, name: str, data: dict) -> ParameterSpec:
|
||||
@@ -38,7 +38,9 @@ class ParameterSpec:
|
||||
return cls(
|
||||
description=str(data["description"]).strip(),
|
||||
why_needed=str(data["why_needed"]).strip(),
|
||||
example=str(data["example"]).strip() if data.get("example") is not None else None,
|
||||
example=str(data["example"]).strip()
|
||||
if data.get("example") is not None
|
||||
else None,
|
||||
)
|
||||
|
||||
|
||||
@@ -54,7 +56,9 @@ class ReturnsSpec:
|
||||
_require(data, "description", f"returns.{key}")
|
||||
fields = data.get("fields") or {}
|
||||
if not isinstance(fields, dict):
|
||||
raise ToolSpecError(f"returns.{key}.fields must be a dict, got {type(fields).__name__}")
|
||||
raise ToolSpecError(
|
||||
f"returns.{key}.fields must be a dict, got {type(fields).__name__}"
|
||||
)
|
||||
return cls(
|
||||
description=str(data["description"]).strip(),
|
||||
fields={str(k): str(v).strip() for k, v in fields.items()},
|
||||
@@ -78,14 +82,14 @@ class ToolSpec:
|
||||
"""Full semantic spec for one tool."""
|
||||
|
||||
name: str
|
||||
summary: str # One-liner — becomes Tool.description.
|
||||
description: str # Longer paragraph.
|
||||
summary: str # One-liner — becomes Tool.description.
|
||||
description: str # Longer paragraph.
|
||||
when_to_use: str
|
||||
when_not_to_use: str | None
|
||||
next_steps: str | None
|
||||
parameters: dict[str, ParameterSpec] # name -> ParameterSpec
|
||||
returns: dict[str, ReturnsSpec] # status_key -> ReturnsSpec
|
||||
cache: CacheSpec | None = None # If present, tool is cached.
|
||||
parameters: dict[str, ParameterSpec] # name -> ParameterSpec
|
||||
returns: dict[str, ReturnsSpec] # status_key -> ReturnsSpec
|
||||
cache: CacheSpec | None = None # If present, tool is cached.
|
||||
|
||||
@classmethod
|
||||
def from_yaml_path(cls, path: Path) -> ToolSpec:
|
||||
@@ -200,6 +204,7 @@ class ToolSpec:
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _require(data: dict, key: str, where: str) -> None:
|
||||
if data.get(key) is None or (isinstance(data[key], str) and not data[key].strip()):
|
||||
raise ToolSpecError(f"{where}: missing required field '{key}'")
|
||||
|
||||
Reference in New Issue
Block a user