Commit 3b9ff5e
authored
feat: CP-6 normalize loop-basic with execution:start/end, tool_call_id, observability.events (#7)
- Add EXECUTION_START and EXECUTION_END imports from amplifier_core.events
- Move asyncio to top-level import (was inline inside execute method)
- Emit execution:start after prompt:submit processing (skipped on deny)
- Wrap main loop body in try/except/finally to emit execution:end on ALL exit paths
- status='completed' on normal completion
- status='cancelled' on cancellation paths (loop-start, post-provider, post-tools)
- status='cancelled' for asyncio.CancelledError exceptions
- status='error' for all other exceptions
- Add tool_call_id to TOOL_PRE event payload
- Add tool_call_id to TOOL_POST event payload
- Add tool_call_id to both TOOL_ERROR event payloads (not-found and exception paths)
- Register observability.events in mount() with execution:start and execution:end
Tests added in tests/test_lifecycle_events.py:
- test_execution_start_fires_with_prompt
- test_execution_end_fires_on_normal_completion
- test_execution_end_response_matches_return_value
- test_execution_start_not_fired_when_prompt_submit_denied
- test_execution_end_fires_cancelled_at_loop_start
- test_execution_end_fires_cancelled_after_provider
- test_execution_end_fires_on_provider_exception
- test_execution_end_fires_exactly_once
- test_tool_pre_includes_tool_call_id
- test_tool_post_includes_tool_call_id
- test_tool_error_not_found_includes_tool_call_id
- test_tool_error_exception_includes_tool_call_id
- test_mount_registers_observability_events1 parent 4448ab0 commit 3b9ff5e
File tree
2 files changed
+1179
-642
lines changed- amplifier_module_loop_basic
- tests
2 files changed
+1179
-642
lines changed
0 commit comments