feat: add solve_task.py direct solver and fix MCP rate limit issues
- Add solve_task.py: fast direct solver (1 LLM call per task, no deepagents overhead) - Add RetryOnRateLimitMiddleware: auto-retry on 429 from any tool - Fix double MCP load: __init__.py cleared, pipeline reuses agent.py journal tools - Fix proxy: add NO_PROXY for openrouter.ai, platform.brojs.ru, git.brojs.ru - Add utility scripts: get_task_ids.py, read_tasks.py - Update run_pipeline.py: TARGET_IDS support, unbuffered output Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+45
-9
@@ -1,28 +1,64 @@
|
||||
"""Запуск пайплайна для выполнения заданий курса."""
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
import traceback
|
||||
|
||||
os.environ["PYTHONIOENCODING"] = "utf-8"
|
||||
# Обходим локальный прокси для OpenRouter (иначе SSL-ошибка)
|
||||
os.environ["NO_PROXY"] = "openrouter.ai,platform.brojs.ru,git.brojs.ru," + os.environ.get("NO_PROXY", "")
|
||||
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
from src.agent.graph.pipeline import pipeline
|
||||
from src.agent.graph.pipeline import pipeline, TaskInfo, process_one_task, route, PipelineState
|
||||
|
||||
# Целевые задания (None = все todo-задания автоматически)
|
||||
TARGET_IDS = [
|
||||
"6a1864f78a94f887e50d46da", # Экзамен: RAG-агент с ChromaDB и веб-поиском
|
||||
]
|
||||
|
||||
|
||||
async def main():
|
||||
print("=== Запуск пайплайна BroJS ===")
|
||||
result = await pipeline.ainvoke(
|
||||
{
|
||||
"tasks": [],
|
||||
|
||||
if TARGET_IDS:
|
||||
tasks = [TaskInfo(id=tid, title="", status="todo") for tid in TARGET_IDS]
|
||||
print(f"Целевые задания: {TARGET_IDS}")
|
||||
initial_state = {
|
||||
"tasks": tasks,
|
||||
"current_index": 0,
|
||||
"results": [],
|
||||
"errors": [],
|
||||
},
|
||||
{"configurable": {"thread_id": "pipeline-main"}},
|
||||
)
|
||||
}
|
||||
from langgraph.graph import StateGraph, START
|
||||
builder = StateGraph(PipelineState)
|
||||
builder.add_node("process_one_task", process_one_task)
|
||||
builder.add_edge(START, "process_one_task")
|
||||
builder.add_conditional_edges(
|
||||
"process_one_task", route,
|
||||
{"process_one_task": "process_one_task", "__end__": "__end__"}
|
||||
)
|
||||
targeted_pipeline = builder.compile()
|
||||
try:
|
||||
result = await targeted_pipeline.ainvoke(
|
||||
initial_state,
|
||||
{"configurable": {"thread_id": "pipeline-targeted"}},
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"КРИТИЧЕСКАЯ ОШИБКА: {e}")
|
||||
traceback.print_exc()
|
||||
return
|
||||
else:
|
||||
try:
|
||||
result = await pipeline.ainvoke(
|
||||
{"tasks": [], "current_index": 0, "results": [], "errors": []},
|
||||
{"configurable": {"thread_id": "pipeline-main"}},
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"КРИТИЧЕСКАЯ ОШИБКА: {e}")
|
||||
traceback.print_exc()
|
||||
return
|
||||
|
||||
print("\n=== Результат пайплайна ===")
|
||||
for r in result.get("results", []):
|
||||
print(f" Task {r['task_id'][:8]}: {r['status']} (mode={r['mode']}, retries={r['retries']})")
|
||||
|
||||
Reference in New Issue
Block a user