Project Agent
The persistent, always-on agent that manages each project — handling @mentions, delegating to specialist agents, and monitoring CI/CD events.
Project Agent
The Project Agent is the persistent hub for every CodeSpar project. There is exactly one Project Agent per project, and it runs continuously. It's the first agent to receive every @mention, CI event, and webhook — then it decides what to do: respond directly, delegate to a specialist agent, or auto-execute based on the project's autonomy level.
Characteristics
| Property | Value |
|---|---|
| Lifecycle | Persistent — runs for the lifetime of the system |
| Cardinality | One per project |
| State | Maintains project context, linked repos, channel mappings |
| Color | Signal Blue (#3B82F6) |
Responsibilities
1. Command Parsing and Routing
Every @mention is first received by the Project Agent. It parses the message to determine what the user is asking for and routes accordingly:
2. Delegation to Specialist Agents
When a task requires specialized processing, the Project Agent spawns an ephemeral agent via the supervisor:
3. Open Question Detection
Not every message is a clear command. When the Project Agent can't match a message to a known command pattern, it treats it as an open question and sends it to Claude Sonnet for a smart, context-aware response:
This uses the TASK_MODEL (default: claude-sonnet-4-20250514) to generate responses that are aware of the project's repository, recent activity, and configuration.
4. CI/CD Event Handling
The Project Agent monitors GitHub webhook events and reacts based on the project's autonomy level:
Workflow Run Events (workflow_run)
When a CI build completes:
Pull Request Events (pull_request)
When a PR is opened or updated:
Push Events (push)
When code is pushed to a monitored branch:
5. Auto-Execution Logic
The Project Agent uses a shouldAutoExecute method to determine whether an action can be performed automatically or requires human approval:
Risk classification examples:
| Action | Risk Level |
|---|---|
| Format code, lint fixes | Low |
| Bug fix PR, code review | Medium |
| Deploy to staging | Medium |
| Deploy to production | Critical (never auto-execute) |
| Data migration | Critical |
| Security config changes | Critical |
Project Linking
Before a Project Agent can interact with a repository, the project must be linked:
This does several things:
- Stores the GitHub repository reference in the project configuration
- Configures the GitHub App/token for API access
- Sets up webhook endpoints for CI events (auto-configuration)
- Enables code-aware features (Task Agent can read/write code, Review Agent can fetch PRs)
Auto-Webhook Configuration
When a project is linked, the Project Agent automatically configures GitHub webhooks to receive events:
Common Commands
| Command | Example | Action |
|---|---|---|
status | @codespar status | Show project health, CI status, recent deploys |
link | @codespar link github:org/repo | Link a GitHub repository |
review | @codespar review PR #42 | Delegate to Review Agent |
fix | @codespar fix the auth bug | Delegate to Task Agent |
deploy | @codespar deploy staging | Delegate to Deploy Agent |
config | @codespar config autonomy L3 | Update project settings |
help | @codespar help | Show available commands |
Configuration
The Project Agent's behavior is configurable per project: