fix(agent): respect temporary chat privacy in tool execution

This commit is contained in:
Xubin Ren committed 2026-09-21 15:24:38 +08:00
1 parent 804e4c4ea6
commit 2640251076
12 files changed
+410 -29

No files matched your search

+11 -2
View File
@@ -38,15 +38,18 @@ class AgentTurnHookSpec:
ephemeral: bool = False
run_extra_hooks_for_ephemeral: bool = False
attributes: dict[str, Any] | None = None
log_content: bool = True
def build_agent_turn_hook(spec: AgentTurnHookSpec) -> AgentHook:
"""Build the hook chain used by ``AgentRunner`` for one turn."""
log_content = spec.log_content and not spec.ephemeral
progress_hook = AgentProgressHook(
events=spec.events,
streaming=spec.streaming,
session_key=spec.session_key,
tool_hint_max_length=spec.tool_hint_max_length,
log_content=log_content,
)
if spec.ephemeral and not spec.run_extra_hooks_for_ephemeral:
return progress_hook
@@ -68,7 +71,10 @@ def build_agent_turn_hook(spec: AgentTurnHookSpec) -> AgentHook:
try:
created_hook = factory(turn_context)
except Exception:
logger.exception("Agent turn hook factory failed: {}", factory)
logger.opt(exception=log_content).error(
"Agent turn hook factory failed: {}",
factory if log_content else type(factory).__name__,
)
continue
if created_hook is not None:
hook_chain.append(created_hook)
@@ -79,7 +85,10 @@ def build_agent_turn_hook(spec: AgentTurnHookSpec) -> AgentHook:
try:
created_hook = factory(turn_context)
except Exception:
logger.exception("Agent turn hook factory failed: {}", factory)
logger.opt(exception=log_content).error(
"Agent turn hook factory failed: {}",
factory if log_content else type(factory).__name__,
)
continue
if created_hook is not None:
hook_chain.append(created_hook)