From 8603547f07c943750affefaba4e55a868cc1b240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Jane=C4=8Dek?= Date: Fri, 6 Feb 2026 13:51:30 +0100 Subject: [PATCH 1/2] docs: add example gpt researcher integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukáš Janeček --- .../example-integrations/langgraph-agent.md | 182 ++++++++++++++++++ docs/docs.json | 6 + 2 files changed, 188 insertions(+) create mode 100644 docs/development/example-integrations/langgraph-agent.md diff --git a/docs/development/example-integrations/langgraph-agent.md b/docs/development/example-integrations/langgraph-agent.md new file mode 100644 index 0000000000..e6cc0a87a3 --- /dev/null +++ b/docs/development/example-integrations/langgraph-agent.md @@ -0,0 +1,182 @@ +--- +title: "LangGraph Agent integration" +description: "How to integrate the agent written in LangGraph." +--- + +An agent written using any framework can be easily integrated into the Agent Stack. In this example, we will demonstrate the integration of a [GPT-Researcher](https://github.com/assafelovic/gpt-researcher) agent built with LangGraph. + +## Prerequisites + +- Agent Stack installed ([Quickstart](../introduction/quickstart)) + +## Agent Integration + + + +```bash +git clone git@github.com:assafelovic/gpt-researcher.git +cd gpt-reasearcher +``` + + +1. Go to the `requirements.txt` file +2. add `agentstack-sdk>=0.5.2` +3. install dependencies `pip install -r requirements.txt` + + + + +Replace following code in the `main.py` file: + +```python +# type: ignore +from backend.server.app import app + +if __name__ == "__main__": + import uvicorn + + logger.info("Starting server...") + uvicorn.run(app, host="0.0.0.0", port=8000) +``` + +by the following code: + +```python +# type: ignore + +from agentstack_sdk.server import Server +from agentstack_sdk.server.context import RunContext +from agentstack_sdk.a2a.types import AgentMessage + +server = Server() + +@server.agent( + name="GPT Researcher", +) +async def my_wrapped_agent( + input: Message, + context: RunContext +): + user_message = get_message_text(input) + + researcher = GPTResearcher( + query=user_message, report_type="research_report", verbose=True + ) + + await researcher.conduct_research() + standard_report = await researcher.write_report() + yield AgentMessage(text=str(standard_report)) + + +def run(): + server.run(host=os.getenv("HOST", "127.0.0.1"), port=int(os.getenv("PORT", 8000))) + + +if __name__ == "__main__": + run() + +``` + + + + +In terminal: + +```bash +python main.py +``` + +Navigate to [http://localhost:8334](http://localhost:8334) and you should see the agent in the list. + + + + +Update `main.ts`: + +```python +# type: ignore + +from agentstack_sdk.a2a.extensions import ( + LLMServiceExtensionSpec, + LLMServiceExtensionServer +) + +async def my_wrapped_agent( + input: Message, + context: RunContext, + llm: Annotated[ + LLMServiceExtensionServer, + LLMServiceExtensionSpec.single_demand( + suggested=( + "watsonx:meta-llama/llama-3-3-70b-instruct", + "watsonx:openai/gpt-oss-120b", + ) + ), + ], +): + if llm and llm.data and llm.data.llm_fulfillments: + # Get LLM configuration + # Single demand is resolved to default (unless specified otherwise) + llm_config = llm.data.llm_fulfillments.get("default") + model = f"openai:{llm_config.api_model}" + + os.environ["OPENAI_API_KEY"] = llm_config.api_key + os.environ["OPENAI_API_BASE"] = llm_config.api_base + os.environ["FAST_LLM"] = model + os.environ["SMART_LLM"] = model + os.environ["STRATEGIC_LLM"] = model + +``` + + + +Update `main.ts`: + +```python +# type: ignore +from agentstack_sdk.a2a.extensions import ( + LLMServiceExtensionSpec, + LLMServiceExtensionServer, + TrajectoryExtensionServer, + TrajectoryExtensionSpec +) + +async def my_wrapped_agent( + input: Message, + context: RunContext, + trajectory: Annotated[TrajectoryExtensionServer, TrajectoryExtensionSpec()], + llm: Annotated[ + LLMServiceExtensionServer, + LLMServiceExtensionSpec.single_demand( + suggested=( + "watsonx:meta-llama/llama-3-3-70b-instruct", + "watsonx:openai/gpt-oss-120b", + ) + ), + ], +): +``` + +and: + +```python +# type: ignore + class LogHandler: + async def on_tool_start(self, tool_name, **kwargs): + await context.yield_async(trajectory.trajectory_metadata(title=tool_name, content=str(kwargs))) + + async def on_agent_action(self, action, **kwargs): + await context.yield_async(trajectory.trajectory_metadata(title=action, content=str(kwargs))) + + async def on_research_step(self, step, details): + await context.yield_async(trajectory.trajectory_metadata(title=step, content=str(details))) + + + # Initialize the researcher + researcher = GPTResearcher( + query=user_message, report_type="research_report", verbose=True, log_handler=LogHandler() + ) +``` + + + diff --git a/docs/docs.json b/docs/docs.json index 257c1d470a..22934ac4c4 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -142,6 +142,12 @@ "development/agent-integration/canvas" ] }, + { + "group": "Example Integrations", + "pages": [ + "development/example-integrations/langgraph-agent" + ] + }, { "group": "Reference", "pages": [ From bd55c8a073fded84c41726ac0cd3faa0e3cd4236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Jane=C4=8Dek?= Date: Fri, 6 Feb 2026 14:14:35 +0100 Subject: [PATCH 2/2] fixup! docs: add example gpt researcher integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukáš Janeček --- .../example-integrations/langgraph-agent.md | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/docs/development/example-integrations/langgraph-agent.md b/docs/development/example-integrations/langgraph-agent.md index e6cc0a87a3..d2d2df064d 100644 --- a/docs/development/example-integrations/langgraph-agent.md +++ b/docs/development/example-integrations/langgraph-agent.md @@ -1,32 +1,33 @@ --- -title: "LangGraph Agent integration" +title: "GPT Researcher (LangGraph Agent) integration" description: "How to integrate the agent written in LangGraph." --- -An agent written using any framework can be easily integrated into the Agent Stack. In this example, we will demonstrate the integration of a [GPT-Researcher](https://github.com/assafelovic/gpt-researcher) agent built with LangGraph. +Integrating an agent written in any framework into AgentStack is straightforward. In this example, we will demonstrate how to integrate a [GPT-Researcher](https://github.com/assafelovic/gpt-researcher) agent built with LangGraph. ## Prerequisites -- Agent Stack installed ([Quickstart](../introduction/quickstart)) +- AgentStack installed ([Quickstart](../introduction/quickstart)) ## Agent Integration - + ```bash git clone git@github.com:assafelovic/gpt-researcher.git -cd gpt-reasearcher +cd gpt-researcher ``` + -1. Go to the `requirements.txt` file -2. add `agentstack-sdk>=0.5.2` -3. install dependencies `pip install -r requirements.txt` +1. Open the `requirements.txt` file. +2. Add `agentstack-sdk>=0.5.2`. +3. Install the dependencies: `pip install -r requirements.txt`. -Replace following code in the `main.py` file: +Replace the code in the `main.py` file: ```python # type: ignore @@ -39,11 +40,10 @@ if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=8000) ``` -by the following code: +with the following: ```python # type: ignore - from agentstack_sdk.server import Server from agentstack_sdk.server.context import RunContext from agentstack_sdk.a2a.types import AgentMessage @@ -74,28 +74,26 @@ def run(): if __name__ == "__main__": run() - ``` - + -In terminal: +In your terminal: ```bash python main.py ``` -Navigate to [http://localhost:8334](http://localhost:8334) and you should see the agent in the list. +Navigate to [http://localhost:8334](http://localhost:8334) to see your agent in the list. - + -Update `main.ts`: +Update `main.py` to use the provided LLM configuration: ```python # type: ignore - from agentstack_sdk.a2a.extensions import ( LLMServiceExtensionSpec, LLMServiceExtensionServer @@ -129,8 +127,9 @@ async def my_wrapped_agent( ``` - -Update `main.ts`: + + +Update `main.py` to include trajectory metadata: ```python # type: ignore @@ -155,13 +154,9 @@ async def my_wrapped_agent( ), ], ): -``` - -and: + # ... previous configuration code ... -```python -# type: ignore - class LogHandler: + class LogHandler: async def on_tool_start(self, tool_name, **kwargs): await context.yield_async(trajectory.trajectory_metadata(title=tool_name, content=str(kwargs))) @@ -172,11 +167,10 @@ and: await context.yield_async(trajectory.trajectory_metadata(title=step, content=str(details))) - # Initialize the researcher + # Initialize the researcher with the log handler researcher = GPTResearcher( query=user_message, report_type="research_report", verbose=True, log_handler=LogHandler() ) ``` -