MCPcopy Index your code
hub / github.com/AutoForgeAI/autoforge / run_autonomous_agent

Function run_autonomous_agent

agent.py:137–444  ·  view source on GitHub ↗

Run the autonomous agent loop. Args: project_dir: Directory for the project model: Claude model to use max_iterations: Maximum number of iterations (None for unlimited) yolo_mode: If True, skip browser testing in coding agent prompts feature_id: If s

(
    project_dir: Path,
    model: str,
    max_iterations: Optional[int] = None,
    yolo_mode: bool = False,
    feature_id: Optional[int] = None,
    feature_ids: Optional[list[int]] = None,
    agent_type: Optional[str] = None,
    testing_feature_id: Optional[int] = None,
    testing_feature_ids: Optional[list[int]] = None,
)

Source from the content-addressed store, hash-verified

135
136
137async def run_autonomous_agent(
138 project_dir: Path,
139 model: str,
140 max_iterations: Optional[int] = None,
141 yolo_mode: bool = False,
142 feature_id: Optional[int] = None,
143 feature_ids: Optional[list[int]] = None,
144 agent_type: Optional[str] = None,
145 testing_feature_id: Optional[int] = None,
146 testing_feature_ids: Optional[list[int]] = None,
147) -> None:
148 """
149 Run the autonomous agent loop.
150
151 Args:
152 project_dir: Directory for the project
153 model: Claude model to use
154 max_iterations: Maximum number of iterations (None for unlimited)
155 yolo_mode: If True, skip browser testing in coding agent prompts
156 feature_id: If set, work only on this specific feature (used by orchestrator for coding agents)
157 feature_ids: If set, work on these features in batch (used by orchestrator for batch mode)
158 agent_type: Type of agent: "initializer", "coding", "testing", or None (auto-detect)
159 testing_feature_id: For testing agents, the pre-claimed feature ID to test (legacy single mode)
160 testing_feature_ids: For testing agents, list of feature IDs to batch test
161 """
162 print("\n" + "=" * 70)
163 print(" AUTONOMOUS CODING AGENT")
164 print("=" * 70)
165 print(f"\nProject directory: {project_dir}")
166 print(f"Model: {model}")
167 if agent_type:
168 print(f"Agent type: {agent_type}")
169 if yolo_mode:
170 print("Mode: YOLO (testing agents disabled)")
171 if feature_ids and len(feature_ids) > 1:
172 print(f"Feature batch: {', '.join(f'#{fid}' for fid in feature_ids)}")
173 elif feature_id:
174 print(f"Feature assignment: #{feature_id}")
175 if max_iterations:
176 print(f"Max iterations: {max_iterations}")
177 else:
178 print("Max iterations: Unlimited (will run until completion)")
179 print()
180
181 # Create project directory
182 project_dir.mkdir(parents=True, exist_ok=True)
183
184 # Determine agent type if not explicitly set
185 if agent_type is None:
186 # Auto-detect based on whether we have features
187 # (This path is for legacy compatibility - orchestrator should always set agent_type)
188 is_first_run = not has_features(project_dir)
189 if is_first_run:
190 agent_type = "initializer"
191 else:
192 agent_type = "coding"
193
194 is_initializer = agent_type == "initializer"

Callers 1

mainFunction · 0.90

Calls 15

has_featuresFunction · 0.90
copy_spec_to_projectFunction · 0.90
print_progress_summaryFunction · 0.90
count_passing_testsFunction · 0.90
print_session_headerFunction · 0.90
create_clientFunction · 0.90
get_initializer_promptFunction · 0.90
get_testing_promptFunction · 0.90
get_batch_feature_promptFunction · 0.90
get_coding_promptFunction · 0.90
is_rate_limit_errorFunction · 0.90

Tested by

no test coverage detected