[PR #1047] [MERGED] fix(docs): prompt_with_context in rag tutorial #1248

Closed
opened 2026-02-17 17:22:00 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/1047
Author: @baihengaead
Created: 10/21/2025
Status: Merged
Merged: 10/21/2025
Merged by: @mdrxy

Base: mainHead: patch-1


📝 Commits (3)

  • 9153d1d fix(docs): update the outdated sample code
  • 16cf746 tweaks
  • eae5af9 Merge branch 'main' into patch-1

📊 Changes

1 file changed (+56 additions, -126 deletions)

View changed files

📝 src/oss/langchain/rag.mdx (+56 -126)

📄 Description

Type of change

Update the existing document

Language

Python

Description

Update the outdated or incorrect sample code for the RAG chain in the langchain learn document.

Original sample code:

def prompt_with_context(state: AgentState) -> list[MessageLikeRepresentation]:
    ...
    return [{"role": "system", "content": system_message}, *list(state["messages"])]


agent = create_agent(llm, tools=[], system_prompt=prompt_with_context)

Repaired sample code:

from langchain.agents.middleware import dynamic_prompt, ModelRequest

@dynamic_prompt
def prompt_with_context(request: ModelRequest) -> str:
    ...
    return system_message

agent = create_agent(llm, tools=[], middleware=[prompt_with_context])

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/1047 **Author:** [@baihengaead](https://github.com/baihengaead) **Created:** 10/21/2025 **Status:** ✅ Merged **Merged:** 10/21/2025 **Merged by:** [@mdrxy](https://github.com/mdrxy) **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (3) - [`9153d1d`](https://github.com/langchain-ai/docs/commit/9153d1d3c6008b8dffec5e932c7177379496edb1) fix(docs): update the outdated sample code - [`16cf746`](https://github.com/langchain-ai/docs/commit/16cf7460930e66f5bedc50e3b7dabdf583c11c1e) tweaks - [`eae5af9`](https://github.com/langchain-ai/docs/commit/eae5af90450ee048964de1ff17314ee5d82485d8) Merge branch 'main' into patch-1 ### 📊 Changes **1 file changed** (+56 additions, -126 deletions) <details> <summary>View changed files</summary> 📝 `src/oss/langchain/rag.mdx` (+56 -126) </details> ### 📄 Description ## Type of change Update the existing document ## Language Python ## Description Update the outdated or incorrect sample code for the [RAG chain in the langchain learn](https://docs.langchain.com/oss/python/langchain/rag#rag-chains) document. Original sample code: ``` python def prompt_with_context(state: AgentState) -> list[MessageLikeRepresentation]: ... return [{"role": "system", "content": system_message}, *list(state["messages"])] agent = create_agent(llm, tools=[], system_prompt=prompt_with_context) ``` Repaired sample code: ``` python from langchain.agents.middleware import dynamic_prompt, ModelRequest @dynamic_prompt def prompt_with_context(request: ModelRequest) -> str: ... return system_message agent = create_agent(llm, tools=[], middleware=[prompt_with_context]) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-17 17:22:00 -05:00
yindo closed this issue 2026-02-17 17:22:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#1248