fix: Telegram files panel "unknown agent id" + task session chatId mismatch breaks conversation - #3
Merged
Secret297-CODER-SOURCE merged 3 commits intoMar 5, 2026
Conversation
Co-authored-by: Secret297-CODER-SOURCE <73541046+Secret297-CODER-SOURCE@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add Telegram agent-to-agent communication feature
feat: Telegram agent-to-agent missions + Core Files panel for telegram-manager
Mar 5, 2026
…lution - agents.files.list "unknown agent id": add telegram.agent.getCoreFileContent WS method; add loadTelegramAgentFiles/loadTelegramAgentFileContent/saveTelegramAgentFile adapters; fix app-render.ts Telegram files panel to use Telegram-specific endpoints - One-message-no-conversation: add resolveEntityId tool to BotAgent + UserBotAgent; in TelegramPlugin.assignTask resolve username → numeric peer ID before storing session; extract resolved ID from opening-message result as belt-and-suspenders fallback Co-authored-by: Secret297-CODER-SOURCE <73541046+Secret297-CODER-SOURCE@users.noreply.github.com>
Copilot
AI
changed the title
feat: Telegram agent-to-agent missions + Core Files panel for telegram-manager
fix: Telegram files panel "unknown agent id" + task session chatId mismatch breaks conversation continuity
Mar 5, 2026
Copilot
AI
changed the title
fix: Telegram files panel "unknown agent id" + task session chatId mismatch breaks conversation continuity
fix: Telegram files panel "unknown agent id" + task session chatId mismatch breaks conversation
Mar 5, 2026
Secret297-CODER-SOURCE
deleted the
copilot/add-telegram-agent-communication
branch
March 5, 2026 13:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent bugs: Telegram "Files" panel called the wrong WS endpoints (returning
INVALID_REQUEST: unknown agent id), and task sessions stored username chatIds that never matched incoming numeric peer IDs, so the agent went silent after the opening message.Summary
agents.files.list/get/setwith Telegram plugin UUIDs. Those endpoints only resolve against the main OpenClaw config — every call returnedINVALID_REQUEST: unknown agent id.assignTaskstored the raw chatId (e.g."@worker_297") in the session. Telegram delivers incoming messages with numeric peer IDs ("123456789").getTaskSessionlookup never matched → agent sent opening message then stopped responding.telegram.agent.getCoreFileContentendpoint; addedloadTelegramAgentFiles/Content/saveadapters that route throughtelegram.agent.*; wired Telegram files panel to use them. AddedresolveEntityIdtool to both agent types;assignTasknow resolves username → numeric peer ID before persisting the session, with opening-message result as fallback.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
@user) now maintain a full conversation — subsequent replies are handled by the AI engine.Security Impact (required)
NoNoYes—resolveEntityIdcallsbot.api.getChat()(grammy) orclient.getEntity()(gramjs) once at assignment time to resolve username → numeric ID. Read-only; gramjs caches entities so subsequent lookups are free.Yes— newresolveEntityIdtool on both agent types. Read-only (no sends or mutations).NogetChat(username)only works for supergroups/channels or users who have started the bot. If resolution fails, catch block falls through to original chatId and the opening-message fallback still attempts recovery — worst case is pre-fix behavior.Repro + Verification
Environment
TG_API_ID/TG_API_HASHset; at least one bot or userbot configuredSteps
Bug 1
Bug 2
telegram.agent.assignTaskwithchatId: "@someuser"+openingMessageExpected
Actual
INVALID_REQUEST: unknown agent idin WS log; panel shows errorEvidence
INVALID_REQUESTpattern this eliminatespnpm tsgoclean,pnpm check0 new errors/warningsHuman Verification (required)
isNumericTelegramIdhelper used uniformly in all three regex-guarded spots; filename allowlist ingetCoreFileContentmatchessetCoreFile.resolveEntityIdskipped; opening message fails → session persisted with best-effort chatId; file missing →getCoreFileContentreturns empty string so editor opens blank.getChatbehavior for private users who haven't messaged the bot.Compatibility / Migration
YesNoNoFailure Recovery (if this breaks)
resolveEntityIdcases fromBotAgent/UserBotAgentcallTool; revertassignTaskblock inTelegramPlugin.ts; restore threeloadAgentFiles/loadAgentFileContent/saveAgentFilecalls inapp-render.ts.extensions/telegram-manager/src/TelegramPlugin.ts,src/agents/BotAgent.ts,src/agents/UserBotAgent.ts,ui/src/ui/app-render.ts,ui/src/ui/controllers/telegram.tstelegram.agent.getCoreFiles404/error → files panel blank;resolveEntityIdthrows unexpectedly at task assignment time.Risks and Mitigations
resolveEntityIdadds a Telegram API round-trip toassignTaskfor username-style chatIds.getChat(username)limited to chats the bot can access.Original prompt
Overview
Two related features need to be added to the
extensions/telegram-managerextension and theui/src/uifrontend:Feature 1: Telegram Agent-to-Agent Communication with Master-Controlled Goals
Implement a system where a master Telegram agent can assign a goal/task to one or more sub-agents, and those sub-agents communicate with each other via Telegram to accomplish the goal.
Backend (
extensions/telegram-manager/)1. New types in
extensions/telegram-manager/src/types.tsAdd the following new types:
Update
BehaviorConfigunion to includeCommunicationBehavior.2. New storage methods in
extensions/telegram-manager/src/storage/TelegramStorage.tsAdd SQLite table
agent_missionsandagent_communication_messageswith appropriate schema. Add CRUD methods:saveMission(mission: AgentMission): voidgetMission(id: string): AgentMission | nullgetAllMissions(): AgentMission[]updateMissionStatus(id: string, status: string, completedAt?: string): voiddeleteMission(id: string): voidsaveCommMessage(msg: AgentCommunicationMessage): voidgetCommMessages(missionId: string, limit?: number): AgentCommunicationMessage[]3. New
AgentCommunicationBusinextensions/telegram-manager/src/agents/AgentCommunicationBus.tsCreate a new class that:
AgentManagerandTelegramStoragecreateMission(masterAgentId, title, goal, participantIds, systemPrompt?): AgentMissioncompleteMission(missionId: string): voidsendAgentMessage(fromAgentId, toAgentId, missionId, content): Promise<AgentCommunicationMessage>agentManager.callTool(toAgentId, "sendMessage", ...)to actually deliver the message via Telegram from the sending agent to a special internal channelgetMissionMessages(missionId, limit?): AgentCommunicationMessage[]getMissions(): AgentMission[]getMission(id): AgentMission | null4. Wire into
AgentManagerinextensions/telegram-manager/src/agents/AgentManager.tsAdd a
commBus: AgentCommunicationBusfield (initialized ininit()). Expose methods:createMission(...)→ delegates tocommBuscompleteMission(missionId)→ delegates tocommBussendAgentMessage(fromAgentId, toAgentId, missionId, content)→ delegates tocommBusgetMissionMessages(missionId, limit?)→ delegates tocommBusgetMissions()→ delegates tocommBusgetMission(id)→ delegates tocommBus5. New WebSocket methods in
extensions/telegram-manager/src/TelegramPlugin.tsAdd these new cases to the
switchinhandleMessage:6. Register new methods in
extensions/telegram-manager/index.tsAdd all the new
telegram.mission.*andtelegram.agent.sendMessage_to_agentmethods to theTELEGRAM_METHODSarray.Also extend the
telegramManagerTooldescription to document the new mission/communication actions.Feature 2: Core Files Panel in Telegram Manager UI
The main OpenClaw agent UI has a "Core Files" panel (shown in the screenshot
) that displays workspace files like
AGENTS.md,SOUL.md,TOOLS.md,IDENTITY.md,USER.md,HEARTBEAT.md,BOOTSTRAP.md, andMEMORY.md. Each Telegram agent should have a similar Core Files panel in the Telegr...This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.