From Credit Crunch to Code Confidence: Fixing LLM Exports and Charting Our AI Future
A deep dive into our recent dev session, covering a critical LLM provider fix and the exciting new AI-powered features we're building next.
Development sessions are a delicate dance between tackling immediate challenges and laying the groundwork for future innovation. Our most recent session was a perfect example, starting with a critical bug fix that led us to a more robust system, and then shifting gears to outline a truly ambitious roadmap for our AI-powered platform.
The Immediate Challenge: A Tale of Two Providers (and an Empty Wallet)
Our platform relies heavily on Large Language Models (LLMs) to distill complex discussions into actionable insights. A key feature, the discussion knowledge export, hit a snag. Users were experiencing failures, and a quick dive into the logs revealed the culprit: a hardcoded call to the Anthropic API.
The Pain Log: When Credits Run Dry
The "Aha!" moment (or perhaps, the "Oh no!" moment) came when we saw the dreaded HTTP 400 error: "Your credit balance is too low to access the Anthropic API." This is a common, real-world scenario when dealing with multiple API providers and fluctuating usage. Our system, in its previous iteration, was too rigid. It insisted on using Anthropic for this specific export, even when credits were exhausted, and other perfectly capable providers (like Kimi or OpenAI) were available and funded for the tenant.
The Fix: Towards a Smarter, More Resilient Provider Selection
This critical incident spurred an immediate improvement. We recognized the need for a more intelligent, resilient provider selection mechanism.
Our solution involved introducing a new function, resolveWorkingProvider(), within src/server/services/discussion-knowledge.ts. Instead of the static resolveProvider("anthropic", tenantId), this new function now intelligently cycles through available LLM providers. It first attempts to use providers specifically configured for the discussion, and if those fail or are unavailable, it gracefully falls back to other general LLM_PROVIDERS configured for the system.
Here's a simplified conceptual view of the change:
// Before: Rigidly tied to Anthropic
// const provider = resolveProvider("anthropic", tenantId);
// provider.generateDiscussionDigest(...)
// After: Dynamic and resilient
const provider = resolveWorkingProvider(discussionId, tenantId); // Tries discussion-specific, then falls back
// provider.generateDiscussionDigest(...)
We also cleaned up some legacy code, removing the HAIKU_MODEL constant which was no longer relevant with our dynamic model selection. Furthermore, generateDiscussionDigest and extractDiscussionInsights were refactored to directly accept an LLMProvider instance, making the dependency explicit and the code cleaner.
The result? A type-check clean, verified fix that makes our discussion knowledge export feature far more robust, cost-efficient, and less prone to single-provider outages or credit issues. This change, while seemingly small, significantly enhances the reliability of a core feature.
Looking Ahead: Charting the Course for Future Innovation
With the immediate fire extinguished and the system more resilient, we shifted our focus to the future. Our next major feature set aims to transform how teams interact with and leverage the insights generated by our platform.
1. Action Points System
Imagine a dedicated space on project pages where key takeaways from discussions and analyses aren't just noted, but become actionable. Our upcoming Action Points system will do just that. These points will be categorized (e.g., innovation, security, platform, architecture, refactoring, UI/UX), allowing teams to quickly identify and prioritize work. Each action point will serve as a "workflow seed," capable of spawning further tasks and workflows, ensuring no valuable insight gets lost.
2. Cross-Project Pattern Detection
This is where the true power of AI-driven insights scales. The Cross-Project Pattern Detection feature is designed to identify recurring faulty or insecure patterns across multiple projects. If a vulnerability or an inefficient code pattern is found in one project, our system will automatically search other projects within the organization, flagging similar instances and creating "auto-todo" items. This proactive approach will be a game-changer for maintaining code quality and security at scale, with todo lists organized intuitively by project, type, and priority.
3. Persona CRUD with AI-Assisted Creation
To make our AI interactions even more nuanced and effective, we're introducing a comprehensive Persona CRUD (Create, Read, Update, Delete) system. Users will gain a new sidebar menu entry to manage custom personas. The exciting part? AI-assisted creation. Users can describe the desired expertise in free text (e.g., "expert in cloud security, PhD level in distributed systems"), and our system will suggest persona identities with gender-neutral names. This allows teams to simulate diverse perspectives and expertise when interacting with the AI, leading to richer, more well-rounded analyses.
The Technical Underpinnings
To bring these features to life, we've outlined several architectural changes:
- Schema Changes: New models like
ActionPointandAutoTodowill be introduced, and the existingPersonamodel will be expanded to accommodate richer descriptions and AI-generated attributes. - tRPC Routers/Procedures: New tRPC endpoints will be developed to handle the creation, retrieval, updating, and deletion of action points, auto-todos, and personas.
- New Dashboard Pages: Dedicated UI will be built at routes like
/dashboard/action-pointsand/dashboard/personasto provide intuitive user interfaces for managing these new features.
What's Next?
Our immediate next step is to commit the crucial discussion-knowledge.ts export fix, ensuring our current system is as robust as possible. Following that, we'll dive deep into the implementation of these exciting new features, transforming our platform into an even more powerful tool for intelligent development.
Stay tuned for more updates as we build out this ambitious roadmap!