Skip to content

feat: add fast-lane override for immediate response execution#1647

Open
BingqingLyu wants to merge 7 commits into
mainfrom
fork-pr-57239-feature-session-fast-lane-replies
Open

feat: add fast-lane override for immediate response execution#1647
BingqingLyu wants to merge 7 commits into
mainfrom
fork-pr-57239-feature-session-fast-lane-replies

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a fast-lane path for short inbound messages when a session already has an active run
  • bypass followup queueing for eligible quick messages and execute them immediately using an isolated transient run context
  • keep existing queue behavior as default and gate fast-lane behavior behind strict message heuristics
  • add queue-policy support for explicit "run now while active" override and unit coverage

Why

Long-running turns currently block quick follow-up messages in the same session, which creates high perceived latency in fast chat channels (especially Discord). This change preserves the existing safe queue model for normal traffic while allowing low-risk, short messages to get timely responses during busy turns.

What changed

  • src/auto-reply/reply/get-reply-run.ts
    • detect fast-lane candidates (short, single-line, non-command quick phrases)
    • when a run is active and message would be queued, create a transient fast-lane run context
    • append a fast-lane system instruction to keep replies concise and avoid unnecessary tools
    • force immediate execution instead of enqueue-followup for these candidate messages
  • src/auto-reply/reply/agent-runner.ts
    • thread a forceRunNowWhenActive flag into queue-action selection
  • src/auto-reply/reply/queue-policy.ts
    • honor forceRunNowWhenActive by returning run-now even while active
  • src/auto-reply/reply/queue-policy.test.ts
    • add test coverage for the fast-lane override path

Behavior notes

  • default queue behavior remains unchanged for non-fast-lane messages
  • fast-lane only applies when all conditions are met:
    • active run exists
    • current queue mode would follow up
    • active run is not currently streaming
    • message matches quick-message heuristics and is not a control command

Verification

  • pnpm tsgo
  • lints on touched files via IDE diagnostics ✅
  • attempted targeted test:
    • pnpm test -- src/auto-reply/reply/queue-policy.test.ts
    • currently hangs in this local environment before case output (same in serial profile); process was stopped after no progress

Risk / follow-up

  • low-to-moderate: introduces a new execution path under active-session contention
  • follow-up recommended:
    • add integration tests around busy-session fast-lane behavior in get-reply-run / reply-flow
    • validate behavior in Discord channel smoke test (long turn + quick follow-up)

References

Closes openclaw#56880

Harrrdik18 and others added 7 commits March 29, 2026 23:50
- Introduced `forceRunNowWhenActive` parameter to enable immediate execution of replies when certain conditions are met.
- Implemented logic to determine fast-lane candidates based on message characteristics.
- Updated queue policy to respect the new fast-lane behavior.
- Added tests to verify the immediate run functionality when the fast-lane override is enabled.
- Added file system cleanup for transient fast-lane session files after execution.
- Updated queue policy to ensure heartbeat conditions take precedence over fast-lane overrides.
- Modified the runPreparedReply function to handle session management more effectively during fast-lane execution.
- Added a test case to validate the new heartbeat precedence behavior.
- Replaced single fast-lane session file variable with an array to handle multiple files for cleanup.
- Updated cleanup logic to iterate over the array of transient fast-lane files.
- Maintained session key for proper system-event routing during fast-lane execution.
- Introduced `sessionLaneKey` to `RunEmbeddedPiAgentParams` for optional command-lane key overrides.
- Updated `runEmbeddedPiAgent` to utilize `sessionLaneKey` for improved session lane resolution.
- Modified context building in `buildEmbeddedContextFromTemplate` to include `sessionLaneKey`.
- Enhanced `runPreparedReply` to isolate command-lane serialization using `sessionLaneKey` for better queue management.
…reparedReply

- Added `fastMode` property to `FollowupRun` type for improved configuration options.
- Updated `runPreparedReply` to explicitly type `followupRun` as `FollowupRun` for better type safety.
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.

Concurrent message handling per session (async agent turns)

3 participants