-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add PostgreSQL database analysis tool and agent #204
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
Conversation
- Change tool_choice from Required to Auto to let model decide when to use tools - Add loop detection for confirm_extraction calls - Stop extraction after 3+ confirm_extraction calls to prevent infinite loops - This resolves issue where GLM-4.6 repeatedly calls confirm_extraction tool
- Convenience script to run PdfToTextAgent with Zai GLM-4.6 - Uses config from ~/Library/Application Support/nocodo/api.toml - Supports custom prompt and allowed working directories
- Format long lines across agent modules for better readability - Add smart payload redaction in Gemini client to log tool definitions and system prompts only once, reducing log verbosity - Configure HTTP client with no_proxy option Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement read-only PostgreSQL database query execution capabilities, mirroring the existing SQLite reader tool and agent. This provides AI-powered database analysis for PostgreSQL with comprehensive security and credential isolation. Key Features: - Read-only SQL query execution with multi-layer security validation - Connection pooling with sqlx for efficient PostgreSQL access - Credential isolation (agent manages connections, LLM never sees credentials) - Schema auto-discovery using INFORMATION_SCHEMA - Reflection mode for inspecting database structure without writing SQL - Query validation using AST parsing with PostgreSQL dialect - Transaction-level safety with READ ONLY mode - Statement timeout and result set limits Implementation: Tool Layer (nocodo-tools): - Add PostgresReaderRequest/Response types with Query and Reflect modes - Implement PostgresExecutor with connection pooling and query validation - Create formatter for LLM-friendly output - Build reflection queries using INFORMATION_SCHEMA (schemas, tables, columns, indexes, views, foreign keys, constraints, stats) - Multi-layer security: AST validation, keyword blocking, read-only transactions, statement timeouts Agent Layer (nocodo-agents): - Implement PostgresReaderAgent with schema discovery at initialization - Generate dynamic system prompt with discovered table list - Inject connection string into tool calls (hidden from LLM) - Add LLM schema definition for postgres_reader tool - Create standalone runner binary for testing Security Measures: - Only SELECT queries allowed (INSERT/UPDATE/DELETE/DROP blocked) - Connection string never exposed to LLM - BEGIN READ ONLY transaction wrapper - Statement timeout (5 seconds) - Result set limits (max 1000 rows) - AST-based query validation with dangerous keyword scanning Dependencies: - Add sqlx with postgres feature and tokio runtime - Add url crate for connection string parsing - Add testcontainers for integration testing - Feature-gated behind 'postgres' flag Testing: - Unit tests for query validation and connection string parsing - PostgreSQL-specific reflection query tests - Runner binary for manual testing (postgres-reader-runner) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📊 Code Complexity Analysis
💡 Suggestion: This is a large PR with 6412 added lines. Consider:
Automated analysis by GitHub Actions |
🤖 Automated Code Review SummaryThis automated review was generated to help ensure code quality and security standards. Rust Code Analysis
Security Analysis
Recommendations
This review was automatically generated. Please address any issues before merging. |
Summary
Testing