(self, request: TaskRequest)
| 82 | class TaskRunner: |
| 83 | """Execute a single benchmark task through the LangGraph workflow.""" |
| 84 | def run(self, request: TaskRequest) -> TaskResult: |
| 85 | start = time() |
| 86 | context = request.workflow.context |
| 87 | context.history.clear() |
| 88 | context.commands.clear() |
| 89 | context.problem = context.problem_template |
| 90 | context.bind_target(request.ip_addr, request.benchmark.target) |
| 91 | |
| 92 | try: |
| 93 | llm = build_chat_model(request.model, request.config) |
| 94 | graph = request.workflow.compile(llm) |
| 95 | state = context.initial_state() |
| 96 | result = self._invoke_graph( |
| 97 | graph, |
| 98 | state, |
| 99 | recursion_limit=context.recursion_limit(), |
| 100 | ) |
| 101 | runtime = time() - start |
| 102 | status = self._status_from_history(context.history) |
| 103 | return TaskResult( |
| 104 | status=status, |
| 105 | runtime=runtime, |
| 106 | benchmark_name=request.benchmark.name, |
| 107 | model_alias=request.model.alias, |
| 108 | ip_addr=request.ip_addr, |
| 109 | details=build_task_result_details( |
| 110 | target=request.benchmark.target, |
| 111 | benchmark=request.benchmark.to_dict(), |
| 112 | model=request.model.to_dict(), |
| 113 | architecture="FSM", |
| 114 | workflow_name="autopt.workflow.v1", |
| 115 | prompt_bundle_name=request.prompt_bundle_name, |
| 116 | result=serialize_json_value(result), |
| 117 | history=context.history, |
| 118 | commands=context.commands, |
| 119 | prompts=request.prompts.to_dict(), |
| 120 | workflow_edges=request.workflow.edges, |
| 121 | ), |
| 122 | ) |
| 123 | except Exception as exc: |
| 124 | runtime = time() - start |
| 125 | return TaskResult( |
| 126 | status="error", |
| 127 | runtime=runtime, |
| 128 | benchmark_name=request.benchmark.name, |
| 129 | model_alias=request.model.alias, |
| 130 | ip_addr=request.ip_addr, |
| 131 | details=build_task_result_details( |
| 132 | target=request.benchmark.target, |
| 133 | benchmark=request.benchmark.to_dict(), |
| 134 | model=request.model.to_dict(), |
| 135 | architecture="FSM", |
| 136 | workflow_name="autopt.workflow.v1", |
| 137 | prompt_bundle_name=request.prompt_bundle_name, |
| 138 | error=str(exc), |
| 139 | history=context.history, |
| 140 | commands=context.commands, |
| 141 | prompts=request.prompts.to_dict(), |
no test coverage detected