This repository has been archived on 2026-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
orchestrator/agents.py

97 lines
3.6 KiB
Python
Raw Normal View History

from langchain_core.messages import SystemMessage, HumanMessage
from state import OrchestratorState
from models import (
get_implementer,
get_reviewer,
get_researcher,
get_cross_reviewer,
get_scanner,
get_fast_coder,
)
IMPLEMENTER_PROMPT = """You are an implementation agent. You write clean, production-ready code.
Follow the spec exactly. No over-engineering, no unnecessary abstractions.
Return the complete implementation with file paths."""
REVIEWER_PROMPT = """You are a code review agent. Review code changes for correctness, security, and maintainability.
For each issue found, categorize it:
- BLOCK — Must fix before merge. Security vulnerabilities, data loss risks, broken logic.
- FIX — Should fix. Bugs, performance issues, missing error handling at boundaries.
- NIT — Optional. Style, naming, minor improvements.
- QUESTION — Needs clarification. Intent is unclear.
Start with a one-line summary: APPROVE, REQUEST CHANGES, or NEEDS DISCUSSION.
Then list findings grouped by category (BLOCK > FIX > NIT > QUESTION).
If the code is fine, say "No issues found." No praise or filler."""
RESEARCHER_PROMPT = """You are a research agent. Look up documentation, API references, and technical answers.
Be concise and cite sources. Return factual information, not opinions."""
CROSS_REVIEWER_PROMPT = """You are a cross-family code review agent. You provide an independent review perspective.
Review the provided code for bugs, security issues, and improvements.
Categorize findings as BLOCK, FIX, or NIT. Be concise.
Focus on issues that might be missed by the primary development team."""
SCANNER_PROMPT = """You are a large-context analysis agent. You analyze codebases, identify patterns,
check consistency across files, and find structural issues.
Summarize findings concisely with file references."""
FAST_CODER_PROMPT = """You are a fast coding agent for well-specified tasks.
Implement exactly what is asked. No extras, no refactoring beyond scope.
Return complete, working code."""
def implementer_node(state: OrchestratorState) -> dict:
llm = get_implementer()
response = llm.invoke([
SystemMessage(content=IMPLEMENTER_PROMPT),
HumanMessage(content=state["task"]),
])
return {"result": response.content, "messages": [response]}
def reviewer_node(state: OrchestratorState) -> dict:
llm = get_reviewer()
response = llm.invoke([
SystemMessage(content=REVIEWER_PROMPT),
HumanMessage(content=state["task"]),
])
return {"result": response.content, "messages": [response]}
def researcher_node(state: OrchestratorState) -> dict:
llm = get_researcher()
response = llm.invoke([
SystemMessage(content=RESEARCHER_PROMPT),
HumanMessage(content=state["task"]),
])
return {"result": response.content, "messages": [response]}
def cross_reviewer_node(state: OrchestratorState) -> dict:
llm = get_cross_reviewer()
response = llm.invoke([
SystemMessage(content=CROSS_REVIEWER_PROMPT),
HumanMessage(content=state["task"]),
])
return {"result": response.content, "messages": [response]}
def scanner_node(state: OrchestratorState) -> dict:
llm = get_scanner()
response = llm.invoke([
SystemMessage(content=SCANNER_PROMPT),
HumanMessage(content=state["task"]),
])
return {"result": response.content, "messages": [response]}
def fast_coder_node(state: OrchestratorState) -> dict:
llm = get_fast_coder()
response = llm.invoke([
SystemMessage(content=FAST_CODER_PROMPT),
HumanMessage(content=state["task"]),
])
return {"result": response.content, "messages": [response]}