Skip to content

fix(agent) scope steering#1844

Merged
yinwm merged 3 commits intosipeed:refactor/agentfrom
afjcjsbx:fix/scope-steering
Mar 22, 2026
Merged

fix(agent) scope steering#1844
yinwm merged 3 commits intosipeed:refactor/agentfrom
afjcjsbx:fix/scope-steering

Conversation

@afjcjsbx
Copy link
Collaborator

@afjcjsbx afjcjsbx commented Mar 20, 2026

📝 Description

This PR introduces Scoped Steering, moving away from a single global steering queue to a session-isolated architecture. It ensures that messages arriving during an active agent turn are only injected if they belong to the same session scope, preventing cross-conversation message leakage. Additionally, this update adds support for multimodal steering (media/images) and improves the agent loop reliability by adding new polling points to catch late-arriving messages.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

Fixes #

📚 Technical Context (Skip for Docs)

  • Reference URL: N/A
  • Reasoning: - Isolation: Previously, any message arriving while an agent was busy could be "steered" into the active turn, regardless of the sender or chat. Now, messages are matched against the activeScope.
  • Requeueing: Messages not belonging to the current scope are now put back onto the inbound bus to be processed normally later.
  • Multimodal: Enabled Media refs in steering messages, ensuring images are resolved via the media pipeline before being sent to the LLM.
  • Loop Integrity: Added a check after direct LLM responses. If a user sent a message while the LLM was "thinking," the agent now continues the turn instead of delivering a stale response.

🧪 Test Environment

  • Hardware: PC / Server
  • OS: Linux (Debian/Ubuntu)
  • Model/Provider: OpenAI GPT-4o / DeepSeek-V3 (Tested with multimodal capabilities)
  • Channels: Telegram, Discord

📸 Evidence (Optional)

Click to view Logs/Screenshots
  • Verified TestAgentLoop_Steering_DirectResponseContinuesWithQueuedMessage passes.
  • Verified TestAgentLoop_Continue_PreservesSteeringMedia for multimodal support.
  • Confirmed non-scoped messages are requeued correctly via TestDrainBusToSteering_RequeuesDifferentScopeMessage.

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

@afjcjsbx afjcjsbx requested review from alexhoshina and yinwm March 20, 2026 19:13
@sipeed-bot sipeed-bot bot added type: enhancement New feature or request domain: agent go Pull requests that update go code labels Mar 20, 2026
Copy link
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary:

  • ✅ Scoped steering isolation - clean design for preventing cross-conversation leakage
  • ✅ Backwards compatible with fallback queue (__manual__ scope)
  • ✅ Comprehensive test coverage (scope isolation, direct response polling, multimodal support)
  • ✅ Documentation updated alongside code changes
  • ✅ Concurrency-safe (proper mutex usage in steeringQueue)

No blocking issues found. Ready to merge.

@yinwm yinwm merged commit 04def0f into sipeed:refactor/agent Mar 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: agent go Pull requests that update go code type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants