Repository navigation
Conversation
A new Bot session bound to the host's primary Agent, because the plugin never named one. The host offers the primary under its canonical name and rejects the legacy `main` alias, so a runtime that still stores the primary under that alias cannot bind it: the session never opens and every turn fails with AGENT_UNAVAILABLE before the model is reached. A Bot team on such a runtime could not talk to its Bots at all. Every turn failed the same way, and the only trace was the generic "The Agent is temporarily unavailable" notice, which reads like a busy host rather than a session that never opened. The turn now names an Agent when the host cannot bind the default one. The Agents the host offers are tried in turn, primary first, and the one that works is used for the sessions that follow, so the probe happens once instead of on every new session. A continued session keeps the Agent it was created with, and a failure that is not a bind failure is never retried with another Agent. When no Agent can be bound, the host's own failure is reported unchanged. The host log now says which Agent was bound, so the fallback is visible next to the turn that used it.
MyPrototypeWhat
left a comment
There was a problem hiding this comment.
Thanks for the PR. Before going further, I'd like to understand the failure itself.
Main ask: how can we reproduce this?
As far as we can tell, this shouldn't happen on a normal install, so we'd like to see it happen before adding a fallback for it. Could you share:
- The exact error / log output you saw (ideally the full
AGENT_UNAVAILABLEmessage and surrounding lines) - The MiniMax Code version, and how it was installed
- Whether it's reproducible, and if so, the steps
Once we can see it, we'll decide whether the fallback is needed at all.
If the fallback stays (secondary):
- Please only fall back to the primary Agent (or surface the problem to the user in the page) instead of trying every Agent in the list. As written, the loop can end up picking a user-created Agent and then keep using it for all later new sessions, with only a log line (
engine.mjs~898/901).
Housekeeping:
- Version: this bumps to 0.7.8, which #49 also targets. Whichever PR merges second should bump to 0.7.9. Also,
miniapp/node/mcp.mjs:589still reports0.7.0— please keep it in sync withplugin.json/package.json. - Please drop the references to host implementation details from the comment at
engine.mjs:837and from the PR description; keeping them focused on what the plugin does is enough.
Once we have the repro details, we'll take another look. Thanks!
| } catch (error) { | ||
| if (!isBindFailure(error)) throw error; | ||
| const candidates = await this.agentCandidates(); | ||
| for (const candidate of candidates) { |
There was a problem hiding this comment.
If a fallback stays: this tries every Agent in the list, which can include user-created ones. Could we only fall back to the primary Agent, or surface the problem to the user instead?
| for (const candidate of candidates) { | ||
| try { | ||
| const result = await run(candidate.name); | ||
| this.boundAgent = candidate.name; |
There was a problem hiding this comment.
Related: whichever Agent gets picked here is then kept for all later new sessions, with only a log line. Another reason to limit this to the primary Agent or tell the user.
| * The Agents the Host offers, primary first. | ||
| * | ||
| * A new Mini App session binds to the primary Agent unless the caller names one. The Host | ||
| * offers the primary under its canonical name and rejects the legacy `main` alias, so a |
There was a problem hiding this comment.
Could you drop the references to host implementation details here and just describe what the plugin does (e.g. "when the default Agent cannot be bound, …")?
| { | ||
| "name": "minimax-bot", | ||
| "version": "0.7.7", | ||
| "version": "0.7.8", |
There was a problem hiding this comment.
#49 also bumps to 0.7.8 — whichever merges second should go to 0.7.9.
What breaks
A Bot team on some MiniMax Code runtimes cannot talk to its Bots at all. Every turn —
message_bot, a group reply, a scheduled task, a background job — fails the same way and nothing reaches the model:The user only sees the generic "The Agent is temporarily unavailable. Try again shortly" notice, which reads like a busy host rather than a session that never opened. On the machine this was found on, 30 Bot turns had been stored and exactly one had succeeded — the greeting Chief sends when it is created. Nothing had ever worked.
Root cause
docs/agent.mdsays a new Node-initiated session runs as "the primary agent", and that an Agent may be named withrun({ agent }), where the name must come fromagents()and "the aliasmainis rejected".The plugin never named one, so every session was created for the primary Agent, and the primary was resolved by that name alone. That works when the runtime stores the primary under its canonical name. It does not when the runtime still stores the primary under the legacy
mainname: the host thenmainas an alias,while the session service resolves the name against the stored registry row. The two never meet, the session is never created, and the turn fails with
AGENT_UNAVAILABLEatcreate-session.The runtime itself reports the split it is in:
legacy_fallbackmeans the canonical row was never seeded and the runtime is serving the legacy one. The rest of the product copes with that (it resolves the primary through the primary-family chain), but the Mini App session path did not.This is visible in the host bundle, not only in the log:
MINIAPP_AGENT_NAME = 'mavis'— the name the Mini App gateway uses for a new session.listAgentOptions()— offersagent.canonicalViewNameand flagsprimary: name === MINIAPP_AGENT_NAME.agentstable (Agent not found: mavis).The fix
The turn now names an Agent when the host cannot bind the default one:
agenton an existing session, and a session keeps the Agent it was created with.AGENT_UNAVAILABLE) triggers the fallback. A busy session is reported asBUSYand a rejected name asINVALID_ARGUMENTS; neither is a bind failure, so neither is retried with a different Agent.minimax_bot.agent_bound), so the fallback is visible next to the turn that used it.On a runtime where the primary binds normally, nothing changes: the default is tried first and succeeds, exactly as before.
Tests
New
tests/agent-binding.test.mjs(5 cases, mock Agent, no model needed):undefined→mavis→general), and the host log names itagentkey is ever sentnpm run checkreportsplugins/minimax-ai/minimax-bot: OK.Tested environment
MiniMax Code 3.1.2 on macOS. The failure was found on macOS 27.2.0 against a runtime that stores its primary under the legacy
mainname; the fix is a host-version-independent code path and the tests use the plugin's own mock Agent, not a real model. The change was not verified end to end against a real host runtime with the legacy-named primary: the installed package is verified by content digest, so a patched build cannot be loaded locally. The behaviour it relies on —agents()returning{ agents: [{ name, displayName, primary }] }andrun({ agent })naming the Agent of a new session — is the contract indocs/agent.md.Note for the host
The deeper fix belongs in the host: the Mini App session path should resolve the primary through the same primary-family chain the rest of the runtime uses, so that a session created for the canonical name binds the primary even when the runtime still stores it under the legacy alias. The change in this pull request is a plugin-side safety net for that case: it keeps a Bot team working without it, and it is a no-op wherever the primary binds normally.
Need help on this PR? Tag
@codesmith-botwith what you need.