Skip to content

fix(agent): use origin session key for system messages#2041

Open
lppp04808 wants to merge 1 commit intosipeed:mainfrom
lppp04808:fix/session_key
Open

fix(agent): use origin session key for system messages#2041
lppp04808 wants to merge 1 commit intosipeed:mainfrom
lppp04808:fix/session_key

Conversation

@lppp04808
Copy link
Contributor

📝 Description

When an async spawn tool completes, its result is published as a system inbound message. Previously, processSystemMessage always resolved the session key via BuildAgentMainSessionKey, ignoring the origin turn's session and causing the follow-up turn to start in agent:main:main with an empty history instead of the caller's channel session (e.g. agent:main:weixin:direct:<chatID> ).

The root cause was two-fold: the async callback did not forward ts.sessionKey into the published InboundMessage, and processSystemMessage had no way to recover it. Unlike normal channel messages, system messages bypass resolveMessageRoute, so the session key cannot be re-derived from routing config — it must be carried explicitly.

Fix: pass ts.sessionKey in the system InboundMessage.SessionKey field, and have processSystemMessage prefer that value over the BuildAgentMainSessionKey fallback.

🗣️ 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

📚 Technical Context (Skip for Docs)

  • Reference URL:
  • Reasoning:

🧪 Test Environment

  • Hardware:
  • OS:
  • Model/Provider:
  • Channels:

📸 Evidence (Optional)

Click to view Logs/Screenshots

☑️ 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.

@sipeed-bot sipeed-bot bot added type: bug Something isn't working domain: agent go Pull requests that update go code labels Mar 26, 2026
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: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant