GCWing / GCWing/OpenBitFun

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

Aperta
#2,452 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
2.2k
Fork
229
Merge medio
2h 46m
PR unite (30g)
577

Descrizione

## 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).

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
api, backend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.