Plan for Building My Personal AI Agent
Mark0 (1994)
Simulated the activity of brain neurons and built a 3-layer neural network. Prepared training labels (teacher signals) and began training a simple model.
Mark1 Using the OpenAI API (2024–)
Implemented conversational interaction from Python using the OpenAI API.
At the time, none of the AIs were trained on the latest information and could not answer questions about current events, until OpenAI made it possible to call external tools, allowing access to various up-to-date information. I immediately used that external tool-calling feature to register tools for getting the current time, current weather forecasts, and converting place names into latitude and longitude.
Mark2 Using the OpenAI API via Discord
Originally I ran Python and chatted in the command prompt, but I looked into changing the architecture so I could use it while out and about.
I considered integrating LINE with Python, but the LINE API becomes paid once you exceed a certain number of messages. Therefore, I registered this personal AI agent on a free Discord bot instead. This made remote interaction possible.
Mark2.1 Calling External Tools (External APIs) from the OpenAI API
Because the information obtainable from simple external tools was limited, I explored integrating an external search engine. Using the Google API, I made Google Search directly usable from my AI agent, successfully expanding the range of information it could handle.
Mark2.2 Achieving Persistent Conversations with the OpenAI API
The OpenAI API remembers conversation history for a certain period within a session, but once that period passes, a new session is created, or the program restarts, it resets to acting as if we are meeting for the first time. Since OpenAI states that data sent via the OpenAI API is not used for training (as of July 2025), I implemented a mechanism to append past conversations on every turn to avoid this reset. Because all previous conversations are recorded, conversations flow quite consistently without contradictions. From past chats, it also knows where I normally live and my commuting route to the office, so when asked things like the fastest time I can get to work, it factors in my personal route. However, an issue remains: as conversations continue, token consumption snowballs.
Mark2.3 Achieving Persistent Conversations While Saving Costs with the OpenAI API
To reduce token consumption, I implemented a feature that summarizes past conversations.
Mark2.4 Multi-threading Support for Concurrent OpenAI Execution
Because my initial implementation could only call OpenAI one request at a time, I changed it to support multi-threading. This improved responsiveness so that it can handle a new question or request even while another conversation is in progress.
Mark2.5 Managing Persistent Conversation Information by Category
When summarizing conversations, I modified the system to organize and manage the summaries by category.
I reviewed how conversations were being summarized and fine-tuned the prompts accordingly.
Mark2.6 Saving and Retrieving Conversation Memories Autonomously with the OpenAI API for Greater Efficiency (Less Waste, More Savings)
As the summarized data grew larger, loading it on every single conversation turn would still drive up token usage. So I switched to saving summarized information in separate files by category, having OpenAI load only the relevant category files when needed. Along with that, I updated the logic to compare new or changed details from recent conversations against existing per-category summary files and maintain consistent category-specific summaries.
With this in place, when I ask something like “What’s on my schedule today?”, OpenAI automatically loads the task summary file and holds a conversation based on that information.
Mark2.7 Implementing a Timer Feature with the OpenAI API
Extracts information from conversations that I want to be reminded about later and records it as timer data.
When the main program starts, it spawns a separate thread to run the timer worker, reads the registered timer entries, and sends a message to Discord when the scheduled time arrives.
Mark2.8 Managing Favorite Stocks, Fetching Stock Prices, and Visualizing Data (Graphing)
Through conversation with the AI, I can register and list favorite stock tickers. As a separate background task from the AI, I implemented a feature to fetch and store stock price data for favorite tickers. For the AI, I attached stock-management tools so it can provide the required stock data on demand. If stock data is already saved locally, it uses that; otherwise, it fetches it from the internet. However, I hadn’t realized that real-time stock data is a paid commodity. Currently, I process data from about two business days prior within the free tier.
Mark2.9 Multi-tasking External Functions & Other Improvements
Implemented multi-threading support for functions callable by OpenAI. Additionally, unified stock price fetching with graphing: if data is missing when creating a graph, it automatically fetches the data first. Fixed the environment so Japanese characters render properly in graph titles. Converted task list data to JSON format so each task’s deadline and status can be managed properly. Added tracking for the timestamp of the last stock price check.
Mark2.10 Reviewing Data Storage Formats for Easier AI Handling
Changed stored record data to JSON format. Using JSON made it possible for the AI to directly extract, replace, and delete partial data with much higher accuracy.
Mark2.11 Migrating the Implementation to the Responses API
I had been using the Assistants API, but since it was slated for future deprecation, I migrated the implementation to the Responses API. To be honest, it became harder to use. In the original implementation, whenever the AI requested a Tool, I could execute that Tool on the spot and return the result to the AI, but that stopped working the same way (or perhaps I just didn’t know the exact pattern). Adapting to it was quite tough to implement.
P.S.: I got really stuck on this and spent about two weeks debugging (cry).
Mark2.12 Supporting the OpenAI Batch API
As conversation logs with the AI agent grew massive, I implemented Batch API support to compress and organize them in the background. In addition, I refactored the entire codebase and strengthened error handling, making it significantly more stable.
Mark2.13 Google Calendar Integration
Enabled the AI agent to interact with Google Calendar. Enhanced its capabilities so I can check upcoming events or add new schedule items directly through conversation.