Skip to main content

r/LangChain


Qwen 3.8 27B running on a single RTX 5090 researches and creates a full animation using only code.
Qwen 3.8 27B running on a single RTX 5090 researches and creates a full animation using only code.
Discussion
media poster


At what point is multi-agent better than one good agent + tools?
At what point is multi-agent better than one good agent + tools?
Discussion
r/LangChain - At what point is multi-agent better than one good agent + tools?

How do you reduce token consumption when an LLM retry requires sending the entire context again?
How do you reduce token consumption when an LLM retry requires sending the entire context again?
Question | Help

I’m working on an internal AI workflow where an XMP file contains source tables, columns, and metadata. We pass this information to an LLM, which generates a dataflow using an internal MCP tool and our internal dataflow notation.

The current flow is roughly:

"XMP metadata → LLM → MCP tool → Dataflow → Validation"

The issue is with failures.

If the first attempt fails validation, our current approach sends the whole original text/context again along with the failure/error information and asks the LLM to correct the dataflow.

So the retry looks something like:

"Original XMP + instructions + generated dataflow + MCP response/error → LLM retry"

This is causing significantly higher token consumption, especially when the XMP/metadata is large.

I’m looking for advice on how people handle this in production.

A few approaches I’m considering:

- Keep the original metadata outside the conversation and retrieve only the relevant portions during retry

- Send only the failed node/transformation and the validation error to the LLM

- Maintain structured agent state instead of appending the entire conversation

- Summarize/compact the previous attempt before retrying

- Have the MCP tool return a small structured error instead of the full dataflow/context

- Generate the complete dataflow once and use a targeted "repair" step for failures rather than regenerating everything

Question: What architecture/pattern have you found effective for reducing token usage in agentic workflows where the input context is large but retries only need a small portion of it?

Also interested in how you handle context management, retry state, and MCP tool outputs in production coding/data-engineering agents.