-
Notifications
You must be signed in to change notification settings - Fork 37
Small fixes for ag UI #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small fixes for ag UI #481
Conversation
Implemented a new caching mechanism for out-of-the-box workflows to reduce GitHub API rate limits. The cache stores workflows for 5 minutes and checks for existing cached data before making API calls. Updated the ListOOTBWorkflows function to utilize this cache, improving performance and efficiency.
…dapter with persistent client support The AGUI proxy now includes a retry mechanism for background requests to the runner, allowing for up to 15 attempts with exponential backoff if the runner is not ready. Additionally, the ClaudeCodeAdapter has been updated to support a persistent client for improved performance and to handle Google OAuth credentials more effectively, ensuring they are refreshed when available. This change enhances the overall reliability and efficiency of the system.
Updated the ClaudeCodeAdapter to create a fresh client for each run, simplifying the client management process. Removed the app_state dependency for client persistence, ensuring that each request operates independently. Adjusted related logging and cleanup procedures to reflect this change, enhancing reliability and clarity in client handling.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Claude Code ReviewSummaryThis PR implements three key improvements for the AG-UI integration:
Overall Assessment: Good improvements with solid implementation patterns. A few areas need attention before merge. Issues by Severity🚫 Blocker IssuesNone - No critical blockers found. 🔴 Critical Issues1. Race condition in OOTB cache implementation ( The cache has a classic "check-then-act" race condition: // Thread A checks cache (miss)
ootbCache.mu.RLock()
if ootbCache.cacheKey == cacheKey && ... {
// ...
}
ootbCache.mu.RUnlock()
// Thread B could write here
// Thread A fetches from GitHub
entries, err := fetchGitHubDirectoryListing(...)
// Thread A writes cache
ootbCache.mu.Lock()
ootbCache.workflows = workflows
// ...
ootbCache.mu.Unlock()Issue: Multiple concurrent requests during cache miss will all fetch from GitHub, defeating the rate limit protection. Recommendation: Use single-flight pattern or mutex-protected "fetch-in-progress" flag to ensure only one goroutine fetches on cache miss. 2. Potential credential exposure in logs ( While this PR doesn't introduce new token logging, the code proximity to credential handling warrants verification: logger.info("Creating ClaudeSDKClient...")
# Ensure no credentials leak in SDK client initialization logsRecommendation: Audit all log statements in 🟡 Major Issues3. Unbounded goroutine accumulation ( Each go func() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Hour)
defer cancel()
// ...
}()Issue: No tracking or limit on concurrent background goroutines per session. Recommendation:
4. Missing authentication check in OOTB workflows handler ( The func ListOOTBWorkflows(c *gin.Context) {
// No GetK8sClientsForRequest check at the top
project := c.Query("project") // Optional
if project != "" {
// Only checks auth if project provided
k8sClt, sessDyn := GetK8sClientsForRequest(c)
// ...
}
// Continues without auth if no projectIssue: Public endpoint exposure. While OOTB workflows are public, this diverges from the standard pattern requiring authentication for all API operations. Recommendation: Move auth check to top of handler or document why this endpoint is intentionally unauthenticated. 5. Client lifecycle change lacks testing documentation ( Major architectural change from persistent client to fresh client per run: # OLD: client_ctx = create_sdk_client(options)
# client = await client_ctx.__aenter__()
# NEW: client = create_sdk_client(options)
# await client.connect()Issue: No documentation on testing this change or known impacts on conversation continuity. Recommendation: Add comment explaining testing approach and any observed behavior changes (especially for conversation history persistence). 🔵 Minor Issues6. Deprecated string capitalization function ( workflowName = strings.Title(workflowName) // Deprecated since Go 1.18Recommendation: Use 7. Inconsistent error handling in Google credentials ( Function async def _setup_google_credentials(self):
await self._try_copy_google_credentials() # Return value ignoredRecommendation: Either propagate the return value or document why it's intentionally ignored during initial setup. 8. Magic number in retry logic ( maxRetries := 15
retryDelay := 500 * time.MillisecondRecommendation: Extract to constants with explanation: const (
maxRunnerStartupRetries = 15 // ~15s total with exponential backoff
initialRetryDelay = 500 * time.Millisecond
)9. Initial prompt delay hard-coded ( await asyncio.sleep(3) # Hard-coded delayRecommendation: Extract to environment variable or constant with comment explaining why 3 seconds. Positive Highlights✅ Excellent concurrency patterns: Proper use of ✅ Intelligent error recovery: Stale cache fallback when GitHub API fails (lines 1806-1814) is great UX. ✅ Smart retry logic: Exponential backoff with cap prevents thundering herd (agui_proxy.go:196-200). ✅ Clear documentation: Code comments explain WHY, not just WHAT (e.g., "check for newly available Google OAuth credentials"). ✅ Security conscious: Proper token handling patterns maintained (e.g., not logging tokens). ✅ Observability: Good structured logging with context (run IDs, attempt numbers, cache age). RecommendationsPriority 1 (Before Merge)
Priority 2 (Follow-up PR)
Priority 3 (Nice-to-have)
Code Quality Checklist✅ Authentication: Uses user token patterns correctly (where applicable) Overall RecommendationConditional Approval - Address the cache race condition (#1) and document the OOTB auth decision (#4), then this is good to merge. The retry logic and credential refresh improvements are solid additions. The changes follow established patterns and improve reliability. Main concerns are the concurrent cache access pattern and potential goroutine accumulation under load. 🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
fix ootb workflow cache
better google mcp restart
more reliable initial prompt