- AgentStack: A CLI-first framework for rapidly scaffolding AI agent workflows, generating agents, tasks, and tools with seamless CrewAI integration.
- CrewAI: A lightweight multi-agent orchestration engine, perfect for managing sequential or collaborative task execution between agents.
- Dappier: A platform that connects LLMs to real-time, rights-cleared data sources like stock market data, web search, and financial news.
- OpenAI: A powerful language model provider, enabling natural language understanding, real-time reasoning, and content generation.
- AgentOps: A monitoring tool to track, replay, and analyze agent runs with detailed visibility into agent reasoning and tool use.
π οΈ All tasks and agents in this cookbook are generated using agentstack commands and executed in a Python project on your local machine. No notebooks, no server setup required.
π¦ Project Initialization and Setup
To get started, weβll use theagentstack CLI to scaffold a fully functional multi-agent project. This command generates the base project structure, config files, virtual environment, and a ready-to-customize crew.py file with support for tools like Dappier and frameworks like CrewAI.
Step 1: Initialize the Project
Run the following command in your terminal:stock_market_research with the complete project structure.
Step 2: Move Into the Project
Step 3: Activate the Virtual Environment
Activate the virtual environment created byagentstack:
β You now have a fully bootstrapped multi-agent AI project using AgentStack and CrewAI.
π Setting Up API Keys
To enable real-time data access and AI reasoning, youβll need API keys for the following services:- OpenAI β for LLM-powered reasoning and summarization
- Dappier β for real-time stock market data and web search
- AgentOps β for run monitoring and debugging
.env file created during project initialization.
Step 1: Open the .env file
Inside your project root, open .env and update it with your API keys:
- π Get your OpenAI API Key here
- π Get your Dappier API Key here β free credits available
- π Get your AgentOps API Key here - enables run tracking and replay
π§ͺ Make sure to keep these keys private. Do not commit .env to version control.
βοΈ Installing Dependencies
After initializing the project and configuring your API keys, install the required dependencies to ensure everything runs smoothly. The key packages used in this project are:crewaiβ Multi-agent execution and orchestrationagentstackβ CLI toolchain for generating agents, tasks, and crewsdappierβ Real-time data access layer for tools like stock search and newsopenaiβ LLM access to GPT-4o and other OpenAI models (automatically included)
Step 1: Sync All Dependencies from pyproject.toml
If youβre using the pre-generated project setup from agentstack init, run:
uv lockwill generate theuv.lockfile based on yourpyproject.tomluv syncwill install all dependencies into the virtual environment
Step 2: Add or Upgrade Individual Packages
You need to upgrade packages manually, use:β You now have all the required dependencies installed locally and locked for reproducible agent execution.
π€ Creating Agents
Now that your environment is ready, letβs generate the agents that will power the stock market research workflow. These agents are created using the AgentStack CLI and are defined declaratively inagents.yaml.
Step 1: Generate the Agents
Youβll use the following command to scaffold each agent:π§ web_researcher
π stock_insights_analyst
π report_analyst
agents.yaml file.
π₯ These agents will work together to build a real-time stock market report using data from Dappier and OpenAI reasoning.
β Creating Tasks
Each task defines a specific responsibility to be performed by one of the agents. In this project, tasks are tightly scoped and executed sequentially by CrewAI, allowing agents to collaborate and generate a full investment report. Tasks are defined declaratively intasks.yaml and are created using the AgentStack CLI.
Step 1: Generate Tasks Using the CLI
Run the following command to create a new task:task_name(required)--descriptionβ a detailed instruction including{company_name}and{timestamp}--expected_outputβ structured data, tables, or markdown expected from the task--agentβ the agent responsible for this task
π’ company_overview
π financials_performance
π competitive_benchmarking
πΉ real_time_stock_snapshot
π° news_and_sentiment
π generate_investment_report
β οΈ The following two fields must be added manually to thegenerate_investment_reporttask insidetasks.yaml, as they are not currently supported via the CLI:
πͺ All of the above tasks will be executed in sequence using CrewAI when you run the crew.
π οΈ Adding Tools to Agents
Tools enable agents to interact with external services like Dappier. In this project, Dappier provides real-time access to financial data and web search, powering all the data-gathering tasks.Step 1: Add Dappier Tools to the Project
Instead of manually assigning tools one-by-one, you can add all Dappier tools at once using:agentstack.tools["dappier"] registry.
Step 2: Select Specific Tools Per Agent in Code
Instead of assigning tools via CLI, agents in this project filter and attach only the tools they need using a custom helper function increw.py:
π§ web_researcher
π stock_insights_analyst
βοΈ This approach ensures that each agent only receives the exact tool it needs, while keeping tool registration centralized and clean.
π Providing Inputs & Setting Timestamps
Before running the crew, you need to define the runtime inputs that agents and tasks will use. The AgentStack project already includes aninputs.yaml file, which is used to inject these inputs when the crew is executed.
In this project, we use two dynamic inputs:
company_name: The company to analyze (e.g., βteslaβ)timestamp: The current UTC time, injected automatically via code
Step 1: Update inputs.yaml
Open the pre-generated inputs.yaml file and set the target company:
"tesla" to any other publicly traded company.
Step 2: Inject a Real-Time Timestamp in main.py
To provide the current timestamp at execution time, update the run() function in main.py:
- Dynamically inject the current UTC timestamp into the input dictionary
- Allow all tasks referencing
{timestamp}intasks.yamlto use consistent timing context
β±οΈ Timestamped input ensures your reports are anchored to the moment of execution.
π Running the Crew
Once your agents, tasks, tools, and inputs are all set up, youβre ready to run the multi-agent crew. The crew will execute each task in sequence, collaborating to generate a fully structured investment research report using real-time data.Step 1: Run the AgentStack Project
To start the crew execution, run the following command from the project root:- Loads your agents from
agents.yaml - Loads your tasks from
tasks.yaml - Injects inputs from
inputs.yaml(including the runtimetimestamp) - Executes all tasks sequentially via CrewAI
- Stores the final output (e.g., markdown report) in the path defined in
tasks.yaml
β You should see terminal output as each agent completes its assigned task.
Step 2: Debug with --debug Mode (Optional)
For detailed execution traces, run with the debug flag:
- Which agent is running
- Which tool is being used
- Real-time function call results
- Intermediate outputs for each task
π§ͺ Use debug mode to troubleshoot tool usage or model behavior during each step.
Step 3: View the Final Output
After the crew finishes execution, youβll find the generated investment report at:π The final report contains company overviews, financials, benchmarking, stock data, categorized news, and AI-generated insight β all compiled in real time.
π Viewing Agent Run Summary in AgentOps
This project integrates with AgentOps to provide full visibility into agent execution, tool calls, and token usage. By setting theAGENTOPS_API_KEY in your .env file, all runs are automatically tracked.
Below is a sample AgentOps run for this project:
- Duration: 07m 55s
- Cost: $0.1053500
- LLM Calls: 43
- Tool Calls: 9
- Tokens: 73,770
You can view the complete execution trace, including tool calls, function arguments, and model responses in AgentOps.
Note: The AgentOps link shown above is tied to the AgentOps account. To access your own replay, you must run the crew using your personal AGENTOPS_API_KEY.
π Highlights
This cookbook has guided you through setting up and running a local stock market research workflow using AgentStack, CrewAI, and Dappier. You created a structured multi-agent execution that performs real-time investment analysis and generates a markdown-formatted report. Key tools utilized in this cookbook include:- AgentStack: A CLI framework to scaffold agents, tasks, and tools with support for local execution and configuration.
- CrewAI: A lightweight multi-agent framework that executes agents in sequential or collaborative workflows.
- OpenAI: A leading provider of AI models capable of language understanding, summarization, and reasoning, used to power each agentβs intelligence.
- Dappier: A platform that connects agents to real-time, rights-cleared data from trusted sources like stock feeds and web search.
- AgentOps: A tool to track and analyze agent runs, including replay, cost breakdowns, and prompt histories.

