Skip to content

feat: normalize loop-basic with execution lifecycle events and tool_call_id#7

Merged
bkrabach merged 1 commit intomainfrom
feat/event-system-improvements
Mar 6, 2026
Merged

feat: normalize loop-basic with execution lifecycle events and tool_call_id#7
bkrabach merged 1 commit intomainfrom
feat/event-system-improvements

Conversation

@bkrabach
Copy link
Copy Markdown
Collaborator

@bkrabach bkrabach commented Mar 5, 2026

Normalize amplifier-module-loop-basic with execution lifecycle events and tool_call_id support:

  • Added execution:start and execution:end lifecycle events
  • Added tool_call_id in tool event payloads for improved traceability
  • Registered events in observability module

Context

Part of the Event System Improvements for Navigation Graph Support initiative.
Design doc: https://github.com/colombod/amplifier-event-and-data-model-for-context-intelligence

…d, observability.events

- 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_events
@bkrabach bkrabach merged commit 3b9ff5e into main Mar 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant