GCWing / GCWing/OpenBitFun

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

Offen
#2,452 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
2.2k
Forks
229
Ø Merge
2 Std. 46 Min.
Gemergte PRs (30 T.)
577

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
api, backend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.