A personal learning project focused on building Agentic AI systems using the OpenAI Agents SDK. This repository showcases an interactive financial analytics application that combines multi-agent coordination, retrieval-augmented generation (RAG), and natural language interfaces.
Try the app here! IDX AI Assistant
This app demonstrates a modular agent-based workflow:
- 🧭 Orchestrator Agent: Understands user questions and manages sub-agents.
- 🧾 Company Overview Agent: Generates a narrative report of a company in IDX.
- 📊 Trend Analyst Agent: Uses a tool to pull real financial data via API and generate the analysis of the trend with visualization.
- and more (see learning milestone for detail)
All agents are orchestrated using the OpenAI Agents SDK, which provides a structured and extensible framework for building LLM-driven applications.
- 🧠 Multi-agent coordination via OpenAI Agents SDK
- 📈 Real-time financial data retrieval from Sectors.app using API-based RAG
- 🗣️ Natural language interface for user queries
- 📊 Interactive data visualization with Plotly
- 🧪 Built with Streamlit for fast prototyping
- Clone the repo
git clone https://github.com/miqbalrp/agentic-ai.git cd agentic-ai - Set up your environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
- Configure your environment variables
Create a .env file (or .streamlit/secrets.toml) with:
OPENAI_API_KEY=your_openai_key_here SECTORS_API_KEY=your_sectors_app_key_here
- Run the app
streamlit run app.py
This project was inspired by the Agentic Patterns Workshop organized by Supertype. The hands-on session introduced practical techniques for building agent-based applications using modern LLMs and retrieval-augmented generation (RAG). The workshop and its accompanying course material — available at sectors.app/bulletin/agentic-patterns — provided the foundational ideas that sparked the development of this financial analytics app.
For the first version of the app, I implemented several core concepts in Multi-Agent System development:
-
Tool Use, Function Calling, and API-based Retrieval-Augmented Generation (RAG):
I used thefunction_tooldecorator from the OpenAI Agents SDK to integrate real-time data via API calls. The app pulls live IDX stock data from the Sectors.app API, ensuring that the model does not hallucinate or rely on outdated training data. -
Handoff & Delegation Pattern:
To orchestrate task routing, I built atriage_agentresponsible for interpreting user queries and delegating them to the appropriate specialized agent.
-
Pydantic-Based Data Validation:
I learned that even though agents are powerful, it's crucial to validate outputs to ensure consistency and reliability in the orchestration pipeline. I used Pydantic models to enforce strict schemas, which also made integration with Streamlit smoother and more predictable. -
Combined Text + Visualization Reports:
Agents liketrend_analysis_agentandtop_companies_agentnot only generate text summaries but also return structured data for Plotly charts. This dual-output design required strong validation to ensure data and narrative were aligned.
In version 2 of the app, I transitioned from a handoff pattern to the more flexible agent-as-tool concept (as implemented in orchestrator_agent.py).
- This shift allows multiple agents to work together on a single query instead of passing responsibility to just one.
- For example, a query like "Summarize TLKM and show its daily closing trend" would trigger both
company_overview_agentandtrend_analysis_agent, with theorchestrator_agentcoordinating their execution and combining the results.
Note: for reference, I keep the previous version of app that using triage_agent in legacy/app_v1.py
While using agent.as_tool is convenient, I discovered a limitation: you can't explicitly define input schemas per tool using that approach.
- Without input constraints, some important context could be dropped.
- To resolve this, I used
Runner.run()to define strict input parameters for each agent, following guidance from the OpenAI Agents SDK documentation.
This change improved reliability and ensured that each tool-agent receives the exact input it expects.
To ensure the app remains compliant and focused, I implemented an Input Guardrail system to filter unsupported or inappropriate queries:
- ❌ Block queries about companies not listed on IDX
⚠️ Reject queries containing non-compliant language or topics
This input filtering ensures the assistant stays within its intended scope and upholds data integrity and compliance standards.
The current orchestration pattern struggled with multi-step queries, often returning partial or inconsistent results.
For example:
"Find the top 3 companies by revenue and show their trend lines."
The app correctly identified the top companies, but then randomly selected tickers when generating trend lines.
To address this, I refactored the architecture by introducing a Planner–Executor pattern:
- 🧠
planner_agent: interprets the full query and breaks it into sub-tasks - 🛠️
executor_agent: handles each sub-task using the appropriate tool-agent
This change improves consistency and ensures that intermediate results are preserved and passed forward correctly.
After exploring core Agentic AI concepts, the app now supports a Chat Mode, enabling users to interact conversationally—similar to LLM apps like ChatGPT or Gemini—but focused exclusively on IDX-listed companies.
Thanks to Streamlit's Chat Elements (docs), this feature was straightforward to implement:
- 💬 Used
st.session_stateto persist multi-turn conversation - 📊 Maintained structured output to ensure Plotly plots render correctly across chat history
- 🧭 Introduced
chat_triage_agentto handle general conversational inputs (e.g. greetings, feature inquiries)- These messages bypass
InputGuardrail - If a query relates to IDX companies, it’s delegated to
orchestrator_agent
- These messages bypass
This upgrade makes the assistant more natural and accessible to users.
🔜 Next milestone: implementing streaming output for a more responsive experience.
This project is part of my ongoing journey into practical Agentic AI — suggestions and contributions are welcome!


