Unlike traditional systems that follow predefined paths, AI agents are autonomous systems that use large language models (LLMs) to make decisions, adapt to changing requirements, and perform complex reasoning.
In this guide to the self-paced workshop for building a report generation agent, you’ll gain:
Understanding of the four core considerations of any AI agent, including NVIDIA Nemotron, an open model family with open data and weights. A working document generation agent that can research and write reports. Knowledge of how to build agents using LangGraph and OpenRouter. A turnkey, portable development environment. Your own customized agent, ready to share as a NVIDIA Launchable.Video walkthrough
Workshop deployment
Launch the workshop as a NVIDIA Brev Launchable:
Figure 1. Click on the ‘Deploy Now’ button to deploy the NVIDIA DevX Workshop in the cloud
Configuration for setting up secrets
To follow along with this workshop, you’ll need to gather and configure a few project secrets.
OpenRouter API key: This enables access to the NVIDIA Nemotron Nano 9B V2 model through OpenRouter. Tavily API key: This enables access to the Tavily web search API for real-time web search.With your JupyterLab environment running, you can use the Secrets Manager tile under NVIDIA DevX Learning Path in the Jupyterlab Launcher to configure these secrets for your workshop development environment. Verify in the logs tab that the secrets have been added successfully.
Figure 2. Use the “Secrets Manager” tile under the NVIDIA DevX Learning Path section to configure project secrets
Next, locate the NVIDIA DevX Learning Path section of the JupyterLab Launcher. Select the 1. Introduction to Agents tile to open up the lab instructions and get started.
Figure 3. “1. Introduction to Agents” tile in NVIDIA DevX Learning Path to open lab instructions.Introduction to agent architecture
Once your workshop environment is set up, the first section introduces developers to agents. It’s crucial to understand what differentiates agents from simpler AI applications before diving into implementation.
Unlike traditional LLM-based applications, agents can dynamically choose tools, incorporate complex reasoning, and adapt their analysis approach based on the situation at hand. Developers will learn about the four key considerations fundamental to all agents:
Model: An LLM that serves as the brain, deciding which tools to use and how to respond. Tools: Functions that enable the LLM to perform actions like mathematical calculations, database queries, or API calls. Memory and state: Information available to the LLM during and between conversations. Routing: Logic that determines what the agent should do next based on the current state and LLM decisions.You’ll learn how to put these components together to build your first basic, calculator-equipped agent in code/intro_to_agents.ipynb. By the end of this exercise, you’ll have an agent that completes the following:
Report generation components
The rest of this workshop centers around building a multi-layered agentic system using LangGraph and NVIDIA NIM hosted as an OpenRouter endpoint. The architecture consists of four interconnected agentic components, each handling specific aspects of the document generation process:
Initial research: Gather comprehensive information about the topic. Outline planning: Create a structured document outline based on research. Section writing: Generate detailed content for each section with additional research as needed. Final compilation: Assemble all sections into a professional report.Learn and implement the code
Now that we understand the concepts, let’s dive into the technical implementation. We’ll start with the foundational considerations mentioned above and build up to the complete agent:
Choose a model Select tools Build a researcher Build an author Build the final agent Manage and route the agentFoundations: the model
The workshop relies on NVIDIA NIM endpoints for the core model powering the agent. NVIDIA NIM provides high-performance inference capabilities, including:
Tool binding: Native support for function calling. Structured output: Built-in support for Pydantic models. Async operations: Full async/await support for concurrent processing. Enterprise reliability: Production-grade inference infrastructure.This example shows the ChatNVIDIA Connector using NVIDIA NIM hosted as an OpenRouter endpoint.
While clear quality instructions are important in any LLM-based application, they’re especially critical for agents as they remove ambiguity and clarify decision-making processes. One such example from code/docgen_agent/prompts.py is provided as follows:
This prompt shows a few key principles of reliable LLM prompting:
Role specification: Clear definition of the agent’s expertise and responsibilities. Task decomposition: Breaking down complex requirements into specific, actionable steps or criteria. Specificity: References examples of temporal specificity and authoritative sources. Structured inputs / outputs: Specific instructions for desired response structure and expected input structure.Foundations: the tools
The agent’s capabilities are defined through its tools. The workshop uses Tavily, a search API designed specifically for AI agents, as the primary tool for information gathering.
Key architectural decisions in the tools module implementation include:
Async operation: Using `asyncio.gather()` for concurrent searches Deduplication: Helper function preventing redundancy from multiple searches Structured documentation: Google-style docstrings help the LLM understand tool usageNow that we have established a foundational understanding of models and tools in code, let’s assemble them into an actual, working agent. We haven’t explored state management and routing considerations yet, but we’ll revisit them later on once we have our agent components built.
Implementing the researcher
The researcher component of the agent implements the reasoning and action pattern (ReAct), one of the most effective architectures for tool-using agents. This pattern creates a loop where the agent thinks about what to do, takes an action, and then decides on the next steps based on the results. This continues until the agent evaluates that no more actions are needed to complete a task.
Figure 4. A ReAct loop is an effective architecture for tool-using agents to complete a taskThe code for this Researcher component of the agent is implemented in code/docgen_agent/researcher.py and can be tested by code/researcher_client.ipynb.
You can also see each action taken by the researcher during execution.
As well as the final output, including the tool call request, the tool output, and the final message summarizing the results.
Implementing the author
Simple ReAct agents are very powerful, but are often combined with additional steps to do more complicated workflows. The section author needs to perform additional section-related research, but only when requested. Once the necessary research is available, it must use that research to write the section.
In the modified architecture diagram, a gating function has been added before the React-style agent to determine whether additional research is required, as well as a writing step at the end.
Figure 5. ReAct agent loop with section author added to perform additional section-related research when requestedThe code for this researcher component of the agent is implemented in code/docgen_agent/author.py and can be tested by code/author_client.ipynb.
You can also see each action taken by the author during execution.
As well as the final output, which consists of the written section in markdown format.
Implementing the final agent
Using these two components, we can now put together our document generation agent’s workflow. This architecture is the simplest so far—a linear workflow that researches the topic, writes the sections, and compiles the whole, finalized report.
Figure 6. Workflow of reporting agent that researches a topic, writes the sections, and compiles a reportThe code for this researcher component of the agent is implemented in code/docgen_agent/agent.py and can be tested by code/agent_client.ipynb.
You can also see each action taken by the author during execution.
The finalized report will be generated in markdown format. Provided is a sample research report generated by this agent: sample markdown output.
Foundations: state management and routing
With the agent components built, let’s take a step back and explore how to use LangGraph as the agent framework for advanced state management and flow control, connecting all three components together into a single agentic AI system. LangGraph provides a couple of key advantages:
Conditional routing: Conditional edges enable dynamic flow control based on runtime conditions, enabling agents to make intelligent decisions about their next actions. Graph compilation and execution: Compiled graphs can be invoked asynchronously, supporting concurrent execution and complex orchestration patterns essential for multi-agent systems.In the following example from code/docgen_agent/agent.py we can see which components we previously built correspond to which node, as well as the edges that connect, or route, intermediate outputs from one node to the next.
Congratulations! In walking through each step of this developer workshop, you have just built your own LangGraph agent. Test your new agent using the code/agent_client.ipynb notebook.
Summary
Building AI agents requires understanding both the theoretical foundations and practical implementation challenges. This workshop provides a comprehensive path from basic concepts to complex agentic systems, emphasizing hands-on learning with production-grade tools and techniques.
By completing this workshop, developers gain practical experience with:
Fundamental agent concepts: Understanding the difference between workflows and intelligent agents. State management: Implementing complex state transitions and persistence. Tool integration: Creating and managing external tool capabilities. Modern AI stack: Working with LangGraph, NVIDIA NIM, and associated tooling.Learn more
For hands-on learning, tips, and tricks, join our Nemotron Labs Livestream, “Building an AI Agent for Report Generation with NVIDIA Nemotron on OpenRouter” on Tuesday, September 16th at 11am PT.
Try NVIDIA Nemotron on OpenRouter and Hugging Face. See the workshop on GitHub. Ask questions on the Nemotron developer forum or the Nemotron channel on Discord.Stay up to date on Agentic AI, Nemotron, and more by subscribing to NVIDIA news, joining the community, and following NVIDIA AI on LinkedIn, Instagram, X, and Facebook. Explore the self-paced video tutorials and livestreams here.
.png)
7 months ago
English (United States) ·
French (France) ·