mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-02-01 15:03:36 +00:00
fix: prevent PendingRollbackError and add MCP tool support for sessions
- Add explicit session.rollback() in exception handlers for database context managers in features.py, schedules.py, and database.py get_db() to prevent SQLAlchemy PendingRollbackError on failed transactions - Add EXPAND_FEATURE_TOOLS to expand session security settings allow list so the expand skill can use the MCP tools it references - Update assistant session prompt to direct the LLM to call MCP tools directly for feature creation instead of suggesting CLI commands Cherry-picked fixes from PR #92 (closed) with cleaner implementation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -429,5 +429,8 @@ def get_db() -> Session:
|
||||
db = _session_maker()
|
||||
try:
|
||||
yield db
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@@ -71,6 +71,9 @@ def get_db_session(project_dir: Path):
|
||||
session = SessionLocal()
|
||||
try:
|
||||
yield session
|
||||
except Exception:
|
||||
session.rollback()
|
||||
raise
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
|
||||
@@ -84,6 +84,9 @@ def _get_db_session(project_name: str) -> Generator[Tuple[Session, Path], None,
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db, project_path
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ def get_system_prompt(project_name: str, project_dir: Path) -> str:
|
||||
|
||||
Your role is to help users understand the codebase, answer questions about features, and manage the project backlog. You can READ files and CREATE/MANAGE features, but you cannot modify source code.
|
||||
|
||||
You have MCP tools available for feature management. Use them directly by calling the tool -- do not suggest CLI commands, bash commands, or curl commands to the user. You can create features yourself using the feature_create and feature_create_bulk tools.
|
||||
|
||||
## What You CAN Do
|
||||
|
||||
**Codebase Analysis (Read-Only):**
|
||||
@@ -134,17 +136,21 @@ If the user asks you to modify code, explain that you're a project assistant and
|
||||
|
||||
## Creating Features
|
||||
|
||||
When a user asks to add a feature, gather the following information:
|
||||
1. **Category**: A grouping like "Authentication", "API", "UI", "Database"
|
||||
2. **Name**: A concise, descriptive name
|
||||
3. **Description**: What the feature should do
|
||||
4. **Steps**: How to verify/implement the feature (as a list)
|
||||
When a user asks to add a feature, use the `feature_create` or `feature_create_bulk` MCP tools directly:
|
||||
|
||||
For a **single feature**, call `feature_create` with:
|
||||
- category: A grouping like "Authentication", "API", "UI", "Database"
|
||||
- name: A concise, descriptive name
|
||||
- description: What the feature should do
|
||||
- steps: List of verification/implementation steps
|
||||
|
||||
For **multiple features**, call `feature_create_bulk` with an array of feature objects.
|
||||
|
||||
You can ask clarifying questions if the user's request is vague, or make reasonable assumptions for simple requests.
|
||||
|
||||
**Example interaction:**
|
||||
User: "Add a feature for S3 sync"
|
||||
You: I'll create that feature. Let me add it to the backlog...
|
||||
You: I'll create that feature now.
|
||||
[calls feature_create with appropriate parameters]
|
||||
You: Done! I've added "S3 Sync Integration" to your backlog. It's now visible on the kanban board.
|
||||
|
||||
|
||||
@@ -162,6 +162,7 @@ class ExpandChatSession:
|
||||
"allow": [
|
||||
"Read(./**)",
|
||||
"Glob(./**)",
|
||||
*EXPAND_FEATURE_TOOLS,
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user