fix: normalize unicode escape sequences and reformat multi-line expressions across codebase
This commit is contained in:
@@ -92,7 +92,12 @@ class AgenticController:
|
||||
if confidence < 0.6:
|
||||
advice = "Confidence is below 0.6 - gather more context or recall() past lessons before executing."
|
||||
return json.dumps(
|
||||
{"status": "success", "plan_recorded": True, "step_count": len(steps), "advice": advice},
|
||||
{
|
||||
"status": "success",
|
||||
"plan_recorded": True,
|
||||
"step_count": len(steps),
|
||||
"advice": advice,
|
||||
},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
|
||||
@@ -101,13 +106,19 @@ class AgenticController:
|
||||
conclusion = str(arguments.get("conclusion", "")).strip()
|
||||
next_action = str(arguments.get("next_action", "")).strip()
|
||||
if not (observation and conclusion and next_action):
|
||||
raise ToolInputError("reflect requires observation, conclusion, and next_action.")
|
||||
raise ToolInputError(
|
||||
"reflect requires observation, conclusion, and next_action."
|
||||
)
|
||||
tags = str(arguments.get("tags", "") or "").strip()
|
||||
record = self._lessons.add(observation, conclusion, next_action, tags)
|
||||
state = get_state()
|
||||
if state is not None:
|
||||
state.reflections.append(
|
||||
{"observation": observation, "conclusion": conclusion, "next_action": next_action}
|
||||
{
|
||||
"observation": observation,
|
||||
"conclusion": conclusion,
|
||||
"next_action": next_action,
|
||||
}
|
||||
)
|
||||
return json.dumps(
|
||||
{
|
||||
@@ -122,9 +133,15 @@ class AgenticController:
|
||||
query = str(arguments.get("query", "")).strip()
|
||||
if not query:
|
||||
raise ToolInputError("recall requires a query.")
|
||||
k = int(arguments.get("k", self._settings.recall_top_k) or self._settings.recall_top_k)
|
||||
k = int(
|
||||
arguments.get("k", self._settings.recall_top_k)
|
||||
or self._settings.recall_top_k
|
||||
)
|
||||
hits = self._lessons.search(query, k=k)
|
||||
return json.dumps({"status": "success", "count": len(hits), "lessons": hits}, ensure_ascii=False)
|
||||
return json.dumps(
|
||||
{"status": "success", "count": len(hits), "lessons": hits},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
|
||||
async def _forget(self, arguments: dict[str, Any]) -> str:
|
||||
query = str(arguments.get("query", "") or "").strip()
|
||||
@@ -137,7 +154,11 @@ class AgenticController:
|
||||
else:
|
||||
removed = self._lessons.clear()
|
||||
return json.dumps(
|
||||
{"status": "success", "forgotten": removed, "remaining": self._lessons.count()},
|
||||
{
|
||||
"status": "success",
|
||||
"forgotten": removed,
|
||||
"remaining": self._lessons.count(),
|
||||
},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
|
||||
@@ -152,14 +173,20 @@ class AgenticController:
|
||||
if state is not None and confirmed:
|
||||
state.verified = True
|
||||
return json.dumps(
|
||||
{"status": "success", "verified": bool(confirmed), "summary": summary}, ensure_ascii=False
|
||||
{"status": "success", "verified": bool(confirmed), "summary": summary},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
|
||||
async def _spawn(
|
||||
self, prompt: str, tools: list[dict[str, Any]], system_prompt: str = SUB_AGENT_SYSTEM_PROMPT
|
||||
self,
|
||||
prompt: str,
|
||||
tools: list[dict[str, Any]],
|
||||
system_prompt: str = SUB_AGENT_SYSTEM_PROMPT,
|
||||
) -> tuple[str, AgentState]:
|
||||
if self._llm is None or self._dispatcher is None:
|
||||
raise ToolInputError("Sub-agent execution is not available in this context.")
|
||||
raise ToolInputError(
|
||||
"Sub-agent execution is not available in this context."
|
||||
)
|
||||
depth = get_eval_depth()
|
||||
if depth >= MAX_EVAL_DEPTH:
|
||||
raise ToolInputError(
|
||||
@@ -194,7 +221,9 @@ class AgenticController:
|
||||
prompt = str(prompt or "").strip()
|
||||
if not prompt:
|
||||
raise ToolInputError("A non-empty prompt is required.")
|
||||
tools = [tool for tool in self._tools if tool["function"]["name"] != NO_DELEGATE]
|
||||
tools = [
|
||||
tool for tool in self._tools if tool["function"]["name"] != NO_DELEGATE
|
||||
]
|
||||
result, _ = await self._spawn(prompt, tools)
|
||||
return result
|
||||
|
||||
@@ -208,10 +237,13 @@ class AgenticController:
|
||||
tools = [
|
||||
tool
|
||||
for tool in self._tools
|
||||
if tool["function"]["name"] in allowed_set and tool["function"]["name"] != NO_DELEGATE
|
||||
if tool["function"]["name"] in allowed_set
|
||||
and tool["function"]["name"] != NO_DELEGATE
|
||||
]
|
||||
else:
|
||||
tools = [tool for tool in self._tools if tool["function"]["name"] != NO_DELEGATE]
|
||||
tools = [
|
||||
tool for tool in self._tools if tool["function"]["name"] != NO_DELEGATE
|
||||
]
|
||||
result, sub_state = await self._spawn(task, tools)
|
||||
return json.dumps(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user