[Feature]: SessionMessage urgent mid-turn-correction delivery
- Langage dominant
- Rust
- Étoiles
- 2.2k
- Forks
- 229
- Merge moyen
- 2 h 46 min
- PR mergées (30 j)
- 577
Description
## 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).
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- rust
- Domaine
- api, backend
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- Active
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 35/100