perf(agent): skip transcript snapshots without run hooks
This commit is contained in:
1 parent
2ad0da786d
commit
c58bfa71bc
5 files changed
+151
-8
No files matched your search
@@ -13,8 +13,12 @@ from nanobot.agent.hook import (
|
||||
AgentRunHookContext,
|
||||
AgentTurnHookContext,
|
||||
CompositeHook,
|
||||
SDKCaptureHook,
|
||||
)
|
||||
from nanobot.agent.hooks.file_edit_activity import FileEditActivityHook
|
||||
from nanobot.agent.progress_hook import AgentProgressHook
|
||||
from nanobot.agent.tools.context import RequestContext
|
||||
from nanobot.events import NO_EVENTS
|
||||
from nanobot.utils.progress_events import output_events
|
||||
|
||||
|
||||
@@ -351,6 +355,19 @@ def test_composite_wants_streaming_empty():
|
||||
assert hook.wants_streaming() is False
|
||||
|
||||
|
||||
def test_builtin_hooks_detect_run_snapshot_consumers():
|
||||
assert AgentHook().has_run_hooks() is False
|
||||
assert AgentProgressHook().has_run_hooks() is False
|
||||
assert SDKCaptureHook().has_run_hooks() is True
|
||||
assert FileEditActivityHook(events=NO_EVENTS, workspace=None).has_run_hooks() is True
|
||||
|
||||
|
||||
def test_composite_detects_nested_run_snapshot_consumers():
|
||||
progress = AgentProgressHook()
|
||||
assert CompositeHook([AgentHook(), CompositeHook([progress])]).has_run_hooks() is False
|
||||
assert CompositeHook([progress, CompositeHook([SDKCaptureHook()])]).has_run_hooks() is True
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Empty hooks list: behaves like no-op AgentHook
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -359,6 +376,7 @@ def test_composite_wants_streaming_empty():
|
||||
@pytest.mark.asyncio
|
||||
async def test_composite_empty_hooks_no_ops():
|
||||
hook = CompositeHook([])
|
||||
assert hook.has_run_hooks() is False
|
||||
ctx = _ctx()
|
||||
run_ctx = _run_ctx()
|
||||
await hook.before_run(run_ctx)
|
||||
|
||||
Reference in new issue
Block a user