#2462·mcp-use

agent: RunOptions.messages is silently dropped by the LangChain agent

Author: ayaangazaliCreated Sep 6, 2026Updated Sep 28, 2026
Labelsbugagent

What happens

RunOptions.messages is documented as "Provider-neutral messages appended before prompt" and is honoured by the native agent (mcp_agent.ts:380):

typescript
if (options.messages?.length) {
  messages.push(...options.messages);
}

The LangChain agent never reads it. normalizeRunOptions (mcp_agent_langchain.ts:63) maps six of the seven RunOptions fields and leaves messages out, so nothing downstream can see it.

Driving it against the mock harness in tests/unit/telemetry/agent-telemetry.test.ts and inspecting what the executor is invoked with:

typescript
await agent.run({
  prompt: "what is the weather",
  messages: [{ role: "user", content: "CANARY-PROVIDER-MESSAGE" }],
});
FORWARDED: false
INPUTS: {"messages":[{"content":"what is the weather"},{"type":"ai","content":"Test response","tool_calls":[]}]}

The prompt is there; the provided message is gone. No warning, no error. The remote agent does not forward it either.

Why I think this is unintended rather than a native-only option

RunOptions is shared by all three implementations and marks per-implementation limits explicitly. schema says "Structured output is supported by the LangChain entry point and remote agents. The native local agent rejects this option." messages carries no such caveat, and the externalHistory doc describes the ordering in terms of it: "appends it after memory-enabled stored conversation and before messages and the current prompt."

So the documented contract reads as general, and one of the three implementations quietly ignores it.

The part I do not want to decide alone

There is no provider-to-LangChain converter today. messageFormat.ts exports convertExternalHistoryToProvider for the other direction only, so honouring this properly means writing the inverse, including tool-call messages and multimodal content parts. That is a real chunk of new code with mapping decisions in it, which is why I am asking rather than pushing.

  1. Implement it. Add the inverse converter and insert the messages in the native agent's documented order: stored memory, externalHistory, messages, prompt. Most useful, largest diff, and the tool-call and content-part mappings want your eye.
  2. Reject it on the paths that cannot honour it, the way the native agent already rejects schema, and note the limit in the RunOptions.messages doc. Small and honest, but it removes a documented capability instead of adding it.

Happy to send either. Reproduced on canary at 37dc3c8a.