소스 검색

docs: plan tool mode parity fixes

Problem: direct mode can repeat side effects for duplicate provider IDs, schedules batches differently from dual mode, and dual mode ignores its configured event budget.

Risk: duplicate rejection must occur before execution; concurrency must preserve reply order; bounded scheduling remains deferred to Todo 48.
zhenyu.hu 2 주 전
부모
커밋
64e0a18d7f
3개의 변경된 파일51개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 0
      docs/plans/todo-46-configurable-tool-invocation-mode.md
  2. 45 0
      docs/plans/todo-46.1-mode-parity-and-duplicate-call-safety.md
  3. 2 1
      docs/plans/todos.md

+ 4 - 0
docs/plans/todo-46-configurable-tool-invocation-mode.md

@@ -2,6 +2,10 @@
 
 **Status:** in_progress
 
+## Review Update
+
+The initial implementation passed the specification review but remains open pending Todo 46.1 fixes for duplicate provider IDs, direct/dual batch scheduling parity, and symmetric event-budget enforcement.
+
 ## Goal
 
 Add a backend-selectable comparison between the existing fast-reply `dual_agent` path and a `chat_agent_tools` path where ChatAgent receives provider tools directly, while both modes use the same registry, schemas, handlers, event budget, and externally visible tool results.

+ 45 - 0
docs/plans/todo-46.1-mode-parity-and-duplicate-call-safety.md

@@ -0,0 +1,45 @@
+# Todo 46.1 Mode Parity and Duplicate Call Safety Plan
+
+**Status:** in_progress
+
+## Goal
+
+Remove three review-confirmed sources of unsafe or unfair comparison behavior between `dual_agent` and `chat_agent_tools`.
+
+## Scope
+
+- Detect provider tool-call IDs already declared in active direct-mode history before creating a new assistant transcript or executing handlers.
+- Prevent duplicate IDs within a batch and across rounds from causing repeated side effects.
+- Execute direct-mode batches concurrently while preserving provider call order in returned tool messages.
+- Apply `max_event_loops` acceptance to dual text events as well as direct provider calls.
+
+## Boundaries
+
+- A duplicate provider call ID should fail the current runtime before the duplicate handler runs; do not invent a second invalid assistant/tool transcript.
+- Use ordinary `asyncio.gather` parity for this todo; bounded concurrency, conflict classes, terminal barriers, and timeout policy remain Todo 48.
+- Preserve visible reply streaming that occurred before a duplicate is detected.
+
+## Files
+
+- Modify: `src/agent_lab/application/runtime.py`
+- Modify: `tests/test_debug_runtime.py`
+
+## Requirement Execution Loop
+
+### Plan
+
+1. Add RED one-shot and session tests for duplicate provider IDs across rounds; handler call count must remain one.
+2. Add a timing/overlap RED test proving two direct async handlers start before either finishes and replies retain input order.
+3. Add RED dual-mode tests proving events after budget exhaustion are ignored and the loop terminates.
+4. Implement pre-execution ID validation, concurrent direct execution, and symmetric budget acceptance.
+5. Run focused/full verification and renewed reviews.
+
+### Observe / Update
+
+Close Todo 46 only when both modes differ only in orchestration protocol, not duplicate safety, event budget, or handler scheduling semantics.
+
+## Verification
+
+- `UV_CACHE_DIR=.uv-cache uv run pytest tests/test_debug_runtime.py -q`
+- `UV_CACHE_DIR=.uv-cache uv run pytest`
+- `git diff --check`

+ 2 - 1
docs/plans/todos.md

@@ -82,7 +82,8 @@
 | 45.5 | done | `docs/plans/todo-45.5-composed-schema-and-copy-failures.md` | Prevent unrelated composed-schema branches from triggering fallback and normalize argument snapshot failures without exposing validator internals. | Branch-aware composed validation and immutable validation summaries pass direct reproductions. |
 | 45.6 | done | `docs/plans/todo-45.6-mixed-validation-and-handler-snapshot.md` | Require every validation failure to be missing-only before fallback and contain arbitrary handler payload serialization exceptions. | Mixed validation skips fallback; arbitrary handler snapshot exceptions become stable `HANDLER_ERROR`. |
 | 45.7 | done | `docs/plans/todo-45.7-structured-incomplete-mixed-validation.md` | Prevent an explicit structured `complete=False` flag from bypassing substantive validation failures. | Structured incomplete plus substantive errors skips fallback; bounded final gate APPROVED. |
-| 46 | pending | `docs/plans/todo-46-configurable-tool-invocation-mode.md` | Add `dual_agent` and `chat_agent_tools` runtime modes on the shared event kernel. | Runtime tests prove mode-specific requests, direct execution, valid provider history, and dual-mode regression safety. |
+| 46 | in_progress | `docs/plans/todo-46-configurable-tool-invocation-mode.md` | Add `dual_agent` and `chat_agent_tools` runtime modes on the shared event kernel. | Runtime tests prove mode-specific requests, direct execution, valid provider history, and dual-mode regression safety. |
+| 46.1 | in_progress | `docs/plans/todo-46.1-mode-parity-and-duplicate-call-safety.md` | Reject repeated provider call IDs before side effects, align direct multi-call concurrency with dual mode, and enforce the same event budget in both modes. | Duplicate IDs never re-execute handlers; direct calls overlap while preserving reply order; dual ignores text events after budget exhaustion. |
 | 47 | pending | `docs/plans/todo-47-built-in-event-plugins.md` | Add terminate-session, device-volume, schedule, and web-search as built-in plugins on the generic event kernel. | Plugin contract tests cover valid, ambiguous, invalid, idempotent, and failure results for all four events. |
 | 48 | pending | `docs/plans/todo-48-parallel-event-batches.md` | Execute multiple flat events with bounded parallelism, failure isolation, aggregation, and a terminal barrier. | Runtime tests prove independent concurrency, stable result order, isolated failures, and termination after sibling completion or timeout. |
 | 49 | pending | `docs/plans/todo-49-tool-mode-ui-session-restore.md` | Add UI mode selection, workspace/session restoration, and clear EventAgent applicability feedback. | Static/WebSocket tests prove requests, snapshots, loaded sessions, and audit context preserve the selected mode. |