In which component is this bug present?
Bug Description
Notebook: 06-workshops/05-AgentCore-tools/01-Agent-Core-code-interpreter/03-advanced-data-analysis-with-agent-using-code-interpreter/langchain-agent-advanced-data-analysis-code-interpreter.ipynb (and its requirements.txt).
Running the notebook top-to-bottom, the import cell fails:
ImportError: cannot import name 'AgentExecutor' from 'langchain.agents'
Root cause — requirements.txt lists langchain and langchain-aws with no version bound, and the first cell runs !pip install --upgrade -r requirements.txt. That installs LangChain >= 1.0, which removed the legacy AgentExecutor, create_tool_calling_agent, and tool from langchain.agents. The notebook imports all three from langchain.agents and builds the agent with create_tool_calling_agent + AgentExecutor.
Second failure (surfaces after the import is fixed) — with langchain pinned to the 0.3 line, output cells 7.1 (EDA) and 7.2 then fail:
TypeError: string indices must be integers, not 'str'
at print(response["output"][0]["text"]). On the pinned stack AgentExecutor's response["output"] is a plain string, not a content-block list, so the hardcoded [0]["text"] is invalid. The output shape varies by langchain / langchain-aws version.
Workaround / suggested fix
- Pin the deps in
requirements.txt:
langchain-aws<0.3
langchain>=0.3,<1.0
- Make the output print shape-robust in cells 7.1 and 7.2:
print(response["output"] if isinstance(response["output"], str) else response["output"][0]["text"])
(Alternatively, migrate the notebook to the LangChain 1.0 agent API — LangGraph create_agent — and update the output handling accordingly.)
Environment — Amazon SageMaker Studio JupyterLab, Python 3.12; reproduces on a fresh clone, running the notebook as-is.
Related
Screenshots — n/a.
In which component is this bug present?
Bug Description
Notebook:
06-workshops/05-AgentCore-tools/01-Agent-Core-code-interpreter/03-advanced-data-analysis-with-agent-using-code-interpreter/langchain-agent-advanced-data-analysis-code-interpreter.ipynb(and itsrequirements.txt).Running the notebook top-to-bottom, the import cell fails:
Root cause —
requirements.txtlistslangchainandlangchain-awswith no version bound, and the first cell runs!pip install --upgrade -r requirements.txt. That installs LangChain >= 1.0, which removed the legacyAgentExecutor,create_tool_calling_agent, andtoolfromlangchain.agents. The notebook imports all three fromlangchain.agentsand builds the agent withcreate_tool_calling_agent+AgentExecutor.Second failure (surfaces after the import is fixed) — with langchain pinned to the 0.3 line, output cells 7.1 (EDA) and 7.2 then fail:
at
print(response["output"][0]["text"]). On the pinned stackAgentExecutor'sresponse["output"]is a plain string, not a content-block list, so the hardcoded[0]["text"]is invalid. The output shape varies by langchain / langchain-aws version.Workaround / suggested fix
requirements.txt:(Alternatively, migrate the notebook to the LangChain 1.0 agent API — LangGraph
create_agent— and update the output handling accordingly.)Environment — Amazon SageMaker Studio JupyterLab, Python 3.12; reproduces on a fresh clone, running the notebook as-is.
Related
global.anthropic.claude-haiku-4-5(and Sonnet 3.7 is no longer available in Bedrock — see Claude Sonnet 3.7 is no longer supported in Bedrock #1733).create_react_agent) is the same class of LangChain API-drift issue in a different notebook.Screenshots — n/a.