GCWing / GCWing/OpenBitFun

[Feature]: SessionMessage urgent mid-turn-correction delivery

Đang mở
#2,452 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
2.2k
Fork
229
Merge trung bình
2 giờ 46 phút
Pull request đã merge (30 ngày)
577

Mô tả

## Overview

This issue proposes supporting **urgent mid-turn-correction delivery** for the `SessionMessage` agent tool. When the `urgent` flag is set, a message can be steered into a session's **running turn** (instead of starting a new turn), reusing the native turn-steering channel.

## Motivation

The current `SessionMessage` tool always submits to a new turn. In scenarios where a maintenance/operator message must correct an in-progress turn (e.g., inject a remark into the turn currently being processed), starting a new turn is the wrong behavior. This feature adds an `urgent` parameter that re-targets the message to the running turn when one exists, falling back to a normal submission otherwise — so the message is never dropped.

## Proposed implementation

A single functional change split into three stacked commits:

1. **Type layer** — `feat(session-message): add urgent delivery type layer`. Adds `SessionMessageInput.urgent: bool` (`#[serde(default)]`, backward compatible), the `UrgentDelivery` enum, the `resolve_urgent_delivery` / `should_attempt_steering` pure functions, plus `input_schema` / `description` updates and 8 parse/pure test contracts.
2. **State layer** — `feat(scheduler): expose current processing turn id`. Adds a thin read-only `DialogScheduler::current_processing_turn_id(session_id)` query over the native `SessionState::Processing { current_turn_id }`.
3. **Behavior layer** — `feat(session-message): steer urgent messages into running turns`. Integrates into dispatch: steer into the running turn via the native `steer_dialog_turn` channel (reusing the native `AgentDialogSteerRequest`, sender reminder baked into `content`), falls back to `submit_dialog_turn` on idle/reject, and adds the honest fallback note, the three-state result text (steered / created / accepted), and a machine-readable `delivery` field ("steered" / "submitted").

## Alignment with reference behavior

This reimplements the reference behavior while reusing the native dialog-turn structs and the native `UserSteering` injection channel (no custom substitutes).

## Explicitly out of scope

- **Batch per-item `urgent`** (G9) — the base does not yet have the batch framework; out of scope for this change.
- **Reply suppression** (N1 / async reply suppression) — tracked as a separate change.
- **No UI changes** (Rust tool parameters only), so no before/after screenshots apply.

## Testing status

**已测**. Each stacked commit was validated with the real tool-layer feature flag:

- `cargo check -p bitfun-core --features agent-runtime` → 0 errors, 0 new warnings (pre-existing `fork_session_for_plugin` only).
- C1: 8 tests passed (`urgent`).
- C2: 1 test passed (`current_processing_turn_id`).
- C3: full lib regression 1430 passed, 0 failed.
- `cargo clippy -p bitfun-core --features agent-runtime --all-targets` → 0 new warnings; `cargo fmt -p bitfun-core` → clean.

## AI assistance

This change is AI-assisted. Testing status is **已测** (see above).

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start at the SessionMessageInput type and its input_schema and description, then trace dispatch into DialogScheduler and the native steer_dialog_turn and submit_dialog_turn paths. Run the listed agent-runtime checks and tests, including the urgent contracts and current_processing_turn_id test. Done means urgent messages steer a running turn, fall back to submission when needed, and report the stated delivery result.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust
Lĩnh vực
api, backend
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.