feat: add Context Engine plugin for hybrid code search and RAG#10
feat: add Context Engine plugin for hybrid code search and RAG#10TerminallyLazy wants to merge 514 commits intomainfrom
Conversation
Accept upstream's architectural refactors: - Settings UI sections moved from Python to frontend components - User data consolidated under /usr directory - Inline settings modal replaced by stacked modal system - settings.js removed (moved to component stores) Conflicts resolved by accepting upstream for all 5 files. Our skills/backup features will be re-implemented using the new architecture. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…dating skill search functionality. Adjusted skills tool to utilize project context for skill discovery and refined the skills loading process. Updated documentation to reflect changes in skill operations and removed deprecated script execution methods. Uses code_execution_tool for skill scripts instead of execute_scripts from the skills_tool.
The merge in 95de41a inadvertently accepted upstream's change from agent0ai to frdel. This forward-fixes the file without rewriting merge history. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Empty or whitespace-only AI messages cause API validation errors with strict providers (OpenAI, Z.ai, GLM): "Assistant messages must have either content or tool_calls" This is a companion fix to PR agent0ai#927 (response.py KeyError fix). When that fix returns an empty string instead of crashing, the empty string can become an empty AIMessage that fails API validation. Changes: - Pre-compute content before creating message objects - Skip AI messages where content is None, empty, or whitespace-only - Human messages are not filtered (they can be empty per spec) Tested on 4 production A0 instances.
…ages fix: Skip empty AI messages in output_langchain to prevent API rejection
single scrollbar in modals
Text file editor tool plugin
Adds a complete Agent Zero plugin integrating Context Engine — an open-source hybrid code search and RAG system — as a first-class agent capability. Plugin includes: - 8 agent tools: code_search, context_answer, symbol_graph, context_index, ce_memory_store, ce_memory_find, search_tests, search_callers - Async HTTP client wrapping Context Engine's MCP endpoints - Auto-context injection via lifecycle extensions - WebUI dashboard with status, search, and index panels - Settings UI with per-project and per-agent config - Docker Compose overlay for Context Engine services - Sidebar entry and system prompt behavior extension Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have run out of free Bugbot PR reviews for this billing cycle. This will reset on March 3. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
|
Important Review skippedToo many files! This PR contains 154 files, which is 4 over the limit of 150. ⛔ Files ignored due to path filters (146)
📒 Files selected for processing (154)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||||||||||||||||||
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances Agent Zero's modularity, extensibility, and user experience by integrating a new Context Engine plugin for advanced code search and RAG. It introduces a comprehensive plugin system and a standardized 'Skills' framework, replacing older 'Instruments' for more dynamic agent capabilities. The changes also include a major overhaul of the project's documentation, a shift to a centralized Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This is a substantial pull request that introduces a major refactoring to support a new plugin architecture, alongside the new Context Engine plugin. The changes are extensive, touching core components like agent.py, initialize.py, and the settings system. Key improvements include enhanced thread safety in AgentContext using RLock, making many core methods extensible with the @extensible decorator, and a significant overhaul of the subagent and plugin loading mechanisms. The migration of user data to the /usr directory and the replacement of instruments with a more formal skills system are also welcome changes for better organization and functionality.
Overall, the refactoring appears well-executed and sets a strong foundation for future extensibility. I have one specific comment regarding a piece of duplicated code that should be addressed.
| # Activate project if provided | ||
| if project_name: | ||
| try: | ||
| projects.activate_project(context_id, project_name) | ||
| except Exception as e: | ||
| return Response(f'{{"error": "Failed to activate project: {str(e)}"}}', status=400, mimetype="application/json") |
There was a problem hiding this comment.
This block of code for activating a project appears to be a duplicate of the logic in lines 98-109. Having duplicated logic can lead to maintenance issues and potential inconsistencies. The previous block already handles project activation, including more detailed error logging. This second block should be removed to avoid redundancy.
Merge branch 'development' of https://github.com/agent0ai/agent-zero into context-engine-a0-plugin
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…DockerHandler Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… settings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…emove path disclosure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ource Replace non-existent ghcr.io/context-engine-ai/* images with auto-clone from the real GitHub repository. On first deploy, the handler: 1. Clones github.com/Context-Engine-AI/Context-Engine (shallow, --depth 1) 2. Generates .env with Agent Zero-friendly defaults 3. Runs docker compose up -d --build from the cloned repo This makes the deploy toggle fully functional — one click to go from zero to a running Context Engine stack. Also adds context_engine_repo_path setting (default: ~/.context-engine/repo) and removes the broken docker-compose.context-engine.yaml. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…refresh, and cleanup - Validate repo_path stays under home directory to prevent path traversal - Always regenerate .env on deploy (respects user-edited files via marker) - Replace os.getcwd() with configurable host_index_path setting - Add asyncio.Lock to prevent concurrent clone/deploy race conditions - Clean up partial clones on failure so retry works cleanly - Add --remove-orphans to docker compose down - Remove unused 'installed' field from ps response - Add Host Index Path setting to UI and default_config.yaml Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…and container grouping Three issues fixed: 1. Qdrant version incompatibility: upstream docker-compose.yml pulls qdrant:latest (v1.17.0) but Context Engine bundles qdrant-client 1.15.1 (max minor diff is 1). Generate docker-compose.override.yml to pin qdrant to v1.16.1. 2. Dashboard 404: MCP streamable-http transport serves at /mcp path, not root. Update default endpoints from http://localhost:8003 to http://localhost:8003/mcp (same for 8002). Also update config.json so existing installs pick up the fix. 3. Container grouping: Add -p context-engine to all docker compose commands so containers appear grouped in Docker Desktop. Drop explicit -f flag in favor of cwd auto-discovery (also picks up the override file automatically). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… warnings - Override upstream hardcoded subnet (172.20.0.0/16) with auto-assigned IPAM so it doesn't conflict with existing Docker networks - Add _cleanup_old_project() to tear down containers from previous deploys that used the default project name (e.g. "repo") before starting the new "context-engine" project - Add CTXCE_AUTH_SHARED_TOKEN, CTXCE_AUTH_DB_URL, QWEN3_INSTRUCTION_TEXT to .env template to suppress Docker Compose variable warnings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The MCP streamable-http transport returns 406 Not Acceptable unless the client sends Accept: application/json, text/event-stream. The server needs both because it may respond with either a direct JSON body or an SSE stream depending on the request. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The MCP streamable-http transport responds with text/event-stream SSE
frames (event: message\ndata: {json}), not plain application/json.
The client was calling resp.json() which fails on SSE bodies.
Split response parsing into _parse_response() that checks content_type:
- text/event-stream: extract JSON from SSE data lines
- application/json: parse directly
Also extracted _unwrap_mcp_result() for readability.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Context Engine MCP server exposes `qdrant_index_root` (full workspace) and `qdrant_index` (subdirectory), not `index`. Updated: - client.py: index() now calls qdrant_index_root (empty path) or qdrant_index (with subdir), matching the actual MCP tool names - index.py: handler passes subdir/recreate params correctly - ce-dashboard.html: Index tab now explains paths are relative to the mounted workspace, allows empty path for full indexing - ce-dashboard-store.js: triggerIndex allows empty path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The upstream Context Engine repo ships a default .env with HOST_INDEX_PATH=./dev-workspace. Our _generate_env() only recognized files containing our own _AUTOGEN_MARKER as safe to overwrite, so the upstream .env was treated as "user-edited" and never regenerated with the correct host path. This caused the indexer to mount an empty directory, resulting in 0 indexed files and search returning no results. Now checks a list of known default headers (our marker + upstream's "# Environment for local Qdrant") to determine if the file is safe to regenerate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… dir Two fixes for search returning 0 results: 1. EMBEDDING_MODEL in .env template now uses the quantized variant (nomic-ai/nomic-embed-text-v1.5-Q) matching what the embedding service Dockerfile bakes in at build time. Without this, the runtime model name mismatches the cached model, causing startup failure after volume recreation. 2. config.json host_index_path updated from "~" (entire home dir) to the actual project directory for focused indexing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
asyncio.TimeoutError has an empty str() representation, causing the dashboard to show "Unexpected error:" with no message. Now caught explicitly with a helpful timeout message. Indexing operations now use a 300s timeout override instead of the default 10s connection_timeout, since workspace indexing involves scanning/embedding many files and can take several minutes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added a rule to ignore __pycache__ directories within the usr/plugins path to keep the repository clean from Python bytecode files.
User description
Summary
usr/plugins/context-engine/) integrating Context Engine for hybrid code search and RAGWhat's included
Test plan
🤖 Generated with Claude Code
PR Type
Enhancement, Tests
Description
Major infrastructure refactoring with thread-safe context management, WebSocket event routing, and extensible agent lifecycle hooks
Migrated UI server from Flask/Werkzeug to Uvicorn/Starlette ASGI stack with Socket.IO integration and comprehensive WebSocket namespace isolation
Refactored settings system with environment variable support (
A0_SET_prefix), dynamic UI generation, and persistent storage inusr/settings.jsonNew plugin management system with discovery, configuration, and per-project/per-agent toggle support
New skills management module with YAML frontmatter parsing, discovery, and CLI tool for skill lifecycle management
Enhanced project management with git repository cloning, subagent configuration, and hierarchical agent discovery
Improved task scheduler with cancellation support, running task tracking, and state monitor integration
Thread-safe logging with timestamp tracking, agent numbering, and state synchronization
New file utilities with binary detection, conditional text evaluation, and glob-based path discovery
WebSocket security hardening with origin validation (RFC 6455), CSRF/auth enforcement, and namespace-scoped event broadcasting
Chat branching API for creating conversation branches at specific message points
Work directory file operations API for renaming and folder creation
Comprehensive test coverage for WebSocket manager, namespace isolation, security validation, and integration scenarios
Bug fix in memory consolidation plugin import paths
Diagram Walkthrough
File Walkthrough
15 files
settings.py
Major settings refactoring with environment variable supportpython/helpers/settings.py
settings + additional metadata format
get_default_value()function to load settings from environmentvariables with
A0_SET_prefixreplacing with dynamic generation
workdir_*(path, show, max_depth,max_files, max_folders, max_lines, gitignore),
websocket_server_restart_enabled,uvicorn_access_logs_enabled,chat_inherit_projectmemory_recall_*,memory_memorize_*,agent_memory_subdir)tmp/settings.jsontousr/settings.jsonconvert_out()to return flat settings dict with providerlists and options instead of nested sections
_load_sensitive_settings()to centralize loading of auth, APIkeys, and secrets from environment
websocket_manager.py
New WebSocket manager with event routing and bufferingpython/helpers/websocket_manager.py
implementation
management
traffic and connections
route_event_all) andper-connection request handling
TTL-based expiration
skills_cli.py
New CLI tool for Agent Zero skill managementpython/helpers/skills_cli.py
implementation
frontmatter
docs)
requirements)
agent.py
Thread-safe context management and extensible agent lifecycle hooksagent.py
threading.RLock()forconcurrent access to
_contextsdictionary@extensibledecorator to multiple methods enablingplugin/extension hooks throughout agent lifecycle
retry_critical_exception()method forresilient error recovery with configurable retries
subagents.get_paths()helper forbetter plugin/agent hierarchy support
is_running()method to check task execution status and improvedintervention handling
tool execution failures
run_ui.py
WebSocket infrastructure and ASGI migrationrun_ui.py
Socket.IO integration
WebSocketManagerfor managing WebSocket connections andevent routing across namespaces
checks during handshake
register_api_route()helper function
/plugins/and/usr/plugins/routesevents
websocket.py
WebSocket handler base class and origin validationpython/helpers/websocket.py
WebSocketHandlerabstract base class for declarative event handlerdefinition with singleton pattern
WebSocketResulthelper class for standardized success/error responsepayloads
validate_ws_origin()implementing RFC 6455and OWASP CSWSH mitigation
preventing Socket.IO reserved event collisions
on_connect,on_disconnect) and conveniencemethods for emit/broadcast/request operations
branch_chat.py
Chat branching API endpoint implementationplugins/chat_branching/api/branch_chat.py
contexts at specific log message points
preserve conversation history up to branch point
synchronization across tabs
skills.py
New skills management helper module with discovery and validationpython/helpers/skills.py
functionality
Skilldataclass with metadata fields (name, description,version, author, tags, triggers, allowed_tools)
parsing and fallback parser
with deduplication by normalized name
plugins.py
New plugin management system with configuration and discoverypython/helpers/plugins.py
configuration handling
PluginMetadataandPluginListItemmodels for plugininformation
and WebUI extension discovery
state tracking
projects.py
Enhanced project management with git cloning and subagent supportpython/helpers/projects.py
get_project_meta_folder()toget_project_meta()forconsistency
clone_git_project()function for cloning git repositories as A0projects with token support
SubAgentSettingsandGitStatusDataTypedDict classes for projectconfiguration
load_project_subagents()and
save_project_subagents()mark_dirtyparameter forstate monitoring
get_context_memory_subdir()) andmemory folder creation
task_scheduler.py
Task scheduler improvements with cancellation and state monitoringpython/helpers/task_scheduler.py
tmp/schedulertousr/schedulerforpersistence
guids.generate_id()instead ofuuid.uuid4()cancel_running_task()andcancel_tasks_by_context()methods_running_deferred_tasksdictionaryand thread-safe registration
mark_dirty_all()for taskchanges
asyncio.CancelledErrorandasyncio.shield()for graceful cleanupsubagents.py
New subagent management system with hierarchical discoverypython/helpers/subagents.py
plugin, user, and project directories
SubAgentListItemandSubAgentmodels with validation andmerging logic
hierarchical configuration merging
log.py
Thread-safe logging with state monitoring integrationpython/helpers/log.py
threading.RLock()for concurrent accessprotection
tempfield fromLogItemand addedagentnofieldcircular dependencies
_update_item()to perform masking/truncation outside lockfor better concurrency
progress_activeflag and state monitornotifications
files.py
Enhanced file utilities with binary detection and conditionalevaluationpython/helpers/files.py
AGENTS_DIR,PLUGINS_DIR,PROJECTS_DIR,USER_DIR)evaluate_text_conditions()supporting{{if}}...{{endif}}blocksis_probably_binary_file()andis_probably_binary_bytes()read_file_json(),read_file_yaml())get_abs_path_dockerized(),get_abs_path_development(),is_file(),is_dir(),is_in_dir()find_existing_paths_by_pattern()for glob-based path discoverycross-filesystem moves
rename_work_dir_file.py
New work directory file rename and folder creation APIpython/api/rename_work_dir_file.py
directory
renameandcreate-folderactions with validationFileBrowserfor file system operations1 files
memory_consolidation.py
Fixed imports and updated memory consolidation referencesplugins/memory/helpers/memory_consolidation.py
Memoryclass from relative import (.memory)DEFAULT_THRESHOLDfromtools
INSTRUMENTSmemoryarea
3 files
test_websocket_manager.py
Complete WebSocket manager test coveragetests/test_websocket_manager.py
WebSocketManagercovering connectionlifecycle, event routing, and error handling
preservation across requests
isolation
test_websocket_namespaces.py
WebSocket namespace isolation and integration teststests/test_websocket_namespaces.py
event prevention
cross-namespace contamination
within namespace boundaries
test_websocket_namespace_security.py
New WebSocket namespace security test suitetests/test_websocket_namespace_security.py
validation
namespace configurations
missing auth/CSRF scenarios
policies
101 files