Ajustes de estructura
This commit is contained in:
@@ -81,9 +81,11 @@ class BaseAgent:
|
||||
conversation=conversation,
|
||||
)
|
||||
|
||||
# Prepare tool definitions
|
||||
# Prepare tool definitions. plan_mode "off" oculta acai_plan al
|
||||
# modelo (toggle del UI desactivado). "force" la expone normalmente.
|
||||
tool_defs = self._get_allowed_tools(
|
||||
followup_mode=str(session.metadata.get("followup_mode", "none")),
|
||||
plan_mode=str(session.metadata.get("plan_mode", "off") or "off"),
|
||||
)
|
||||
|
||||
# Stream model response
|
||||
@@ -146,6 +148,17 @@ class BaseAgent:
|
||||
turn_blocks_by_index[chunk.block_index] = blk
|
||||
if blk.get("type") == "thinking":
|
||||
blk["thinking"] = blk.get("thinking", "") + chunk.thinking_delta
|
||||
if self.profile.stream_deltas:
|
||||
await self.sse.emit(
|
||||
EventType.AGENT_DELTA,
|
||||
{
|
||||
"agent": self.profile.role,
|
||||
"thinking_delta": chunk.thinking_delta,
|
||||
"block_index": chunk.block_index,
|
||||
"step": step,
|
||||
},
|
||||
session_id=session.session_id,
|
||||
)
|
||||
|
||||
if chunk.thinking_signature and chunk.block_index >= 0:
|
||||
blk = turn_blocks_by_index.get(chunk.block_index)
|
||||
@@ -941,12 +954,18 @@ class BaseAgent:
|
||||
|
||||
# ---- Allowed tools --------------------------------------------------------
|
||||
|
||||
def _get_allowed_tools(self, followup_mode: str = "none") -> list[dict[str, Any]]:
|
||||
def _get_allowed_tools(
|
||||
self,
|
||||
followup_mode: str = "none",
|
||||
plan_mode: str = "force",
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Return tool definitions filtered by this agent's allowed_tools.
|
||||
|
||||
Si el agente tiene `has_planner_tool=True`, anade definiciones sinteticas
|
||||
de `acai_plan` y `acai_plan_advance` (Fase 5: la tool interna no
|
||||
atraviesa MCP — se intercepta en `_execute_tool`).
|
||||
Si el agente tiene `has_planner_tool=True` Y `plan_mode == "force"`,
|
||||
anade definiciones sinteticas de `acai_plan` y `acai_plan_advance`
|
||||
(la tool interna no atraviesa MCP — se intercepta en `_execute_tool`).
|
||||
Cuando `plan_mode != "force"` (toggle del UI desactivado), las tools
|
||||
del planner NO se exponen y el agente ejecuta directo.
|
||||
"""
|
||||
if followup_mode == "transform":
|
||||
return []
|
||||
@@ -958,7 +977,7 @@ class BaseAgent:
|
||||
else:
|
||||
tool_defs = list(all_tools)
|
||||
|
||||
if self.profile.has_planner_tool:
|
||||
if self.profile.has_planner_tool and plan_mode == "force":
|
||||
tool_defs.append({
|
||||
"name": "acai_plan",
|
||||
"description": (
|
||||
|
||||
Reference in New Issue
Block a user