Skip to content

feat(session-message): support urgent mid-turn-correction delivery - #2453

Open
1688mengdie wants to merge 3 commits into
GCWing:mainfrom
BitFun-SIG:g7-urgent
Open

feat(session-message): support urgent mid-turn-correction delivery#2453
1688mengdie wants to merge 3 commits into
GCWing:mainfrom
BitFun-SIG:g7-urgent

Conversation

@1688mengdie

Copy link
Copy Markdown

Summary

Adds urgent mid-turn-correction delivery to the SessionMessage tool. When urgent: true and the target session is processing a turn, the message is steered into that running turn via the native steer_dialog_turn channel; on idle or steering rejection it falls back to a normal submit_dialog_turn submission so the message is never dropped.

Closes #2452

What changed

  • SessionMessageInput.urgent: bool (#[serde(default)], backward compatible)
  • UrgentDelivery enum (Steer { turn_id } / NormalSubmit)
  • resolve_urgent_delivery / should_attempt_steering pure functions
  • DialogScheduler::current_processing_turn_id(session_id) thin read-only query over native SessionState::Processing { current_turn_id }
  • Dispatch integration: steer → fall back → three-state result text (steered / created / accepted) → machine-readable delivery field ("steered" / "submitted")
  • Removed transient #[allow(dead_code)] suppressions now that the type layer is consumed

Commits

  1. fb7d9935bfeat(session-message): add urgent delivery type layer (type layer: urgent field + UrgentDelivery + pure functions + schema + description + 8 tests)
  2. 5934f5dfdfeat(scheduler): expose current processing turn id (thin read-only query over native SessionState::Processing { current_turn_id })
  3. 4a89f2b0ffeat(session-message): steer urgent messages into running turns (dispatch integration via native steer_dialog_turn, reusing native AgentDialogSteerRequest)

Out of scope

  • Batch per-item urgent (G9): the base does not yet have the batch framework.
  • Reply suppression (N1 / async reply suppression): tracked as a separate change.

Testing

已测. Each commit 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

No skipped verification: this is a Rust tool-parameter change with no UI modifications, so no before/after screenshots apply.

AI assistance

AI-assisted. Testing status: 已测 (see above).

user added 3 commits August 24, 2026 17:06
Add the urgent mid-turn-correction type layer to the SessionMessage tool so a
message can target a session's running turn instead of starting a new turn:

- `SessionMessageInput.urgent: bool` (`#[serde(default)]`, backward compatible)
- `UrgentDelivery` enum (`Steer{ turn_id }` / `NormalSubmit`)
- `resolve_urgent_delivery` and `should_attempt_steering` pure functions
- `urgent` in `input_schema` + a "Urgent correction" usage line in `description`
- 8 pure/parse test contracts (the batch-item contract requires the batch
  framework, which is a separate feature and out of scope for this base)

Test:
- cargo check -p bitfun-core --features agent-runtime --jobs 4
  (0 errors, 0 new warnings; only pre-existing `fork_session_for_plugin`)
- cargo test -p bitfun-core --features agent-runtime --jobs 4 urgent (8 passed)
AI: 已测
Add `DialogScheduler::current_processing_turn_id(session_id)` — a thin read-only
query over the native `SessionState::Processing { current_turn_id }` state. This
is the precise turn that `steer_dialog_turn` can target; callers query it first
and fall back to a normal submission when the session is idle.

Test:
- cargo check -p bitfun-core --features agent-runtime --jobs 4
  (0 errors, 0 new warnings; only pre-existing `fork_session_for_plugin`)
- cargo test -p bitfun-core --features agent-runtime --jobs 4 current_processing_turn_id
  (1 passed)
AI: 已测
Integrate urgent delivery behavior into SessionMessage dispatch. When
`urgent: true` and the target session is processing a turn, the message is
steered into that running turn via the native `steer_dialog_turn` channel,
reusing the native `AgentDialogSteerRequest` struct (with the sender identity
reminder baked into `content`). When the target is idle, or steering is
rejected, the message falls back to the normal `submit_dialog_turn`
submission so it is never dropped.

Adds the honest fallback note to the result text, the three-state result
message (steered / created / accepted), and a machine-readable `delivery`
field ("steered" / "submitted"). Removes the transient `#[allow(dead_code)]`
suppressions now that the type layer is consumed.

Test:
- cargo check -p bitfun-core --features agent-runtime --jobs 4
  (0 errors, 0 new warnings; only pre-existing `fork_session_for_plugin`)
- cargo test -p bitfun-core --features agent-runtime --jobs 4 --lib
  (1430 passed, 0 failed)
- cargo clippy -p bitfun-core --features agent-runtime --all-targets (0 new warnings)
- cargo fmt -p bitfun-core (clean)
AI: 已测
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant