MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / run_queue

Function run_queue

core/orchestrator.py:341–511  ·  view source on GitHub ↗

Execute all pending tasks in queue. Each task runs an agent with file context from prior steps. Results chain as context to the next task.

(queue, yolo=False)

Source from the content-addressed store, hash-verified

339
340
341def run_queue(queue, yolo=False):
342 """
343 Execute all pending tasks in queue.
344 Each task runs an agent with file context from prior steps.
345 Results chain as context to the next task.
346 """
347 from core.agent import run_agent
348 from core.display import update_task_display
349 import signal
350
351 prior_results = []
352 interrupted = False
353
354 def handle_interrupt(sig, frame):
355 nonlocal interrupted
356 interrupted = True
357 for t in queue.tasks:
358 if t.status == 'running':
359 t.status = 'pending'
360 queue.save()
361 raise KeyboardInterrupt
362
363 old_handler = signal.signal(signal.SIGINT, handle_interrupt)
364
365 try:
366 for task in queue.tasks:
367 if task.status == 'done':
368 continue
369 if task.status == 'failed':
370 continue
371
372 queue.mark_running(task.id)
373
374 # Build context from prior results
375 context_prefix = ''
376 if prior_results:
377 context_prefix = ('Previous steps completed:\n' +
378 '\n'.join(f'- {r}' for r in prior_results[-3:]) +
379 '\n\n')
380
381 # Inject file contents from prior steps so this subtask
382 # knows what was actually written (not just a summary).
383 file_context = ''
384 if prior_results:
385 files = _collect_project_files()
386 if files:
387 file_context = f"Files created so far:\n\n{files}\n\n"
388
389 # Inject domain-specific guidance based on task content
390 guidance = ''
391 combined = (getattr(queue, 'original_request', '') + ' ' + task.description).lower()
392 if any(k in combined for k in ['http', 'rest', 'api', 'server', 'endpoint']):
393 guidance += '\n' + GUIDANCE_HTTP_SERVER + '\n'
394 if any(k in combined for k in ['test', 'unittest', 'pytest', 'assert']):
395 guidance += '\n' + GUIDANCE_HTTP_TESTING + '\n'
396 if any(k in combined for k in ['sqlite', 'database', '.db', 'accounts']):
397 guidance += '\n' + GUIDANCE_SQLITE + '\n'
398 if any(k in combined for k in ['expense', 'tracker', 'track', 'log', 'record', 'budget', 'note', 'history', 'persist', 'save data', 'store data']):

Callers 1

run_agentFunction · 0.90

Calls 15

classify_breadth_needFunction · 0.90
retrieveFunction · 0.90
run_agentFunction · 0.90
warningFunction · 0.90
update_task_displayFunction · 0.90
_collect_project_filesFunction · 0.85
_is_result_failureFunction · 0.85
_completion_auditFunction · 0.85
mark_runningMethod · 0.80
existsMethod · 0.80
mark_failedMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected