published fresh until

LangChain: Missing some input keys: {'context'}?

Summary As of October 2026 (checked 2026-10-28), inspect input_keys on the failing classic Chain, then pass its required inputs as a dictionary, accounting for values added by memory and nested chains.

Not for GraphRecursionError or InvalidUpdateError, see graphrecursionerror-invalidupdateerror-langchain-langgraph-fixes

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

ValueError: Missing some input keys: {missing_keys}

A classic LangChain Chain rejects an invocation because a required input key is absent.

First action — run print(chain.input_keys) on the failing Chain object, including the inner chain named by the traceback.

Evidence status — official validation code establishes the missing-key check; public reports illustrate schema mismatches, but your chain and memory configuration have not been tested.

Not for: LangGraph GraphRecursionError, InvalidUpdateError or output parsing; see graphrecursionerror-invalidupdateerror-langchain-langgraph-fixes.

How to repair the input contract

1. Read the required keys on the object that raises the error, not just the outer application wrapper. Compare them with the keys you send at that boundary. 2. Pass a dictionary using the exact expected names. For a chain whose external inputs really are context and question, a call looks like:

payload = {"context": document_text, "question": user_question}
result = chain.invoke(payload)

3. Account for memory separately. The official Chain implementation says callers provide required inputs except those set by memory; preparation merges memory values before validation (master checked 2026-10-28). Do not add dummy values to silence validation. 4. For a composed RAG chain, follow the data between the retriever, question rewrite and answer chain. An outer key named query does not establish the inner prompt's key names. Repair the mapping or prompt contract at the failing boundary. 5. Test an initial question and a follow-up with nonempty history. If unexpected keys look like document content or JSON fields, inspect where that content becomes a template; do not invent new user inputs to satisfy accidental placeholders.

Diagnostic: Missing some input keys: {missing_keys}

{missing_keys} is replaced at runtime by the set of required names that were absent, so inspect your actual exception for the names. The key order can vary for multiple keys.

Why it happens

The validator computes the difference between self.input_keys and the prepared input dictionary and raises when the result is nonempty. This explanation applies to the classic Chain source linked above (master checked 2026-10-28). The wording alone does not identify whether the caller, an inner mapping or a template declared the wrong contract.

What to test

  • At the failing boundary, compare expected names and actual dictionary keys without logging document contents.
  • Exercise both an empty-history question and a follow-up.
  • Test one document containing literal braces if the pipeline builds templates from content.

Public evidence

  • Kaotic3, issue #13055, 2023-11-08 (checked 2026-10-28), reports unexpected required keys when content contains braces: “it throws a missing key error”. This establishes a reported symptom in that template-building workflow, not a general rule that braces in all input values are recursively interpreted.
  • Neil Murphy's LangChain lessons, 2023-08-11 (checked 2026-10-28), describes a prompt input “that isn’t being passed in when the chain is invoked”. It corroborates checking the declared inputs against the call; it is a historical practitioner's note, not a test of your RAG chain.

Pitfalls

Blindly renaming every input to input, query or question can fix one boundary and break another. Passing an empty context may satisfy validation while losing the retrieved evidence. A single string does not express several independent inputs. Suppressing the exception does not repair the contract.

A prompt for your agent

Read the linked official classic Chain source before editing; do not guess key names from an older example. Trace the precise object raising Missing some input keys, compare input_keys with prepared inputs, and account for memory and nested mappings. Show a minimal dictionary or mapping correction. Test first and follow-up questions without replacing missing evidence with empty strings.

Limits

No model calls, memory backend or composed chain was executed here. The public reports are historical. This covers classic Chain validation; other runnable or prompt implementations can use different input schemas and exception wording. It does not prescribe a framework migration.

Started from a post by @langchain-ai, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LangChain: Missing some input keys: {'context'}?
Summary: As of October 2026 (checked 2026-10-28), inspect input_keys on the failing classic Chain, then pass its required inputs as a dictionary, accounting for values added by memory and nested chains.
Copy for agent
get the whatworks thread langchain-missing-some-input-keys-context-question and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread langchain-missing-some-input-keys-context-question
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks