feat(R04): immutable turn snapshot, typed agent events, conversation service
EPIC R04 (Team Duy) - the turn lifecycle leaves the widget. R04-T01 domain/agents/conversation_execution_request.py Frozen snapshot of one turn, captured on the UI thread at submit time. The job closure used to read widget/workspace state from inside the worker thread, so a turn could run on a mix of submit-time and later state depending on thread timing. R04-T02 domain/agents/agent_event.py 13 frozen event types replacing untyped emit() dicts, with a two-way bridge so existing widgets keep consuming the legacy shape until EPIC R08. Adds TurnCompletedEvent - the end-of-turn signal the engine never had, which is why a cancelled turn and a failed turn look identical to the UI today. R04-T03 application/conversations/conversation_application_service.py Runs a turn from a request and reports typed events. Never raises across the worker boundary; TurnResult.raise_if_failed() preserves the existing exception-based failure path. begin_turn()/execute_turn() expose the live message list for callers that autosave history mid-run. R04-T04 ui/cowork_tab.py::build_job -> snapshot + service. R04-T05 core/task_executors.py::_run_agent -> same service (was a second, slightly different assembly of the same call). Caught while wiring the bridge: the first event vocabulary had no "notice" event, so Agent Security warnings and auto-compaction notices would have been silently swallowed. Added NoticeEvent plus a test that scans the engine sources for emit() tags and fails when one has no typed counterpart. New: tests/integration/ - real offscreen CoworkTab running a scripted turn end to end (7 tests), including a characterisation of the extra provider call Agent Security spends reviewing each request. Suite: 225 passed, 2.74s. check_imports: PASS. All new files < 400 LOC. 2 pre-existing failures remain in test_config_security.py (EPIC R02/Team Nam). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,2 +1,48 @@
|
||||
"""Domain entities for one agent turn: the request snapshot and the event
|
||||
"""Domain entities for one agent turn: the request snapshot and the typed event
|
||||
stream it produces (EPIC R04)."""
|
||||
|
||||
from .agent_event import (
|
||||
AgentEvent,
|
||||
AssistantDoneEvent,
|
||||
ErrorEvent,
|
||||
HistoryReadyEvent,
|
||||
NoticeEvent,
|
||||
OutputsAddedEvent,
|
||||
OutputsRemovedEvent,
|
||||
PlanUpdatedEvent,
|
||||
ReasoningChunkEvent,
|
||||
TextChunkEvent,
|
||||
ToolCallFinishedEvent,
|
||||
ToolCallStartedEvent,
|
||||
ToolOutputEvent,
|
||||
TurnCompletedEvent,
|
||||
collect_text,
|
||||
event_from_dict,
|
||||
tool_calls,
|
||||
)
|
||||
from .conversation_execution_request import (
|
||||
ConversationExecutionRequest,
|
||||
new_turn_id,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ConversationExecutionRequest",
|
||||
"new_turn_id",
|
||||
"AgentEvent",
|
||||
"TextChunkEvent",
|
||||
"ReasoningChunkEvent",
|
||||
"AssistantDoneEvent",
|
||||
"PlanUpdatedEvent",
|
||||
"ToolCallStartedEvent",
|
||||
"ToolOutputEvent",
|
||||
"ToolCallFinishedEvent",
|
||||
"OutputsAddedEvent",
|
||||
"OutputsRemovedEvent",
|
||||
"NoticeEvent",
|
||||
"HistoryReadyEvent",
|
||||
"TurnCompletedEvent",
|
||||
"ErrorEvent",
|
||||
"event_from_dict",
|
||||
"collect_text",
|
||||
"tool_calls",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user