(active: BackendGeneration, run: AgentRun)
| 3025 | } |
| 3026 | |
| 3027 | private reserveGenerationRun(active: BackendGeneration, run: AgentRun): void { |
| 3028 | if ( |
| 3029 | active.phase !== 'active' || |
| 3030 | this.backendGenerations.get(active.generation) !== active || |
| 3031 | !this.isCurrentGeneration(active) |
| 3032 | ) { |
| 3033 | throw new Error( |
| 3034 | `Backend generation ${active.generation} no longer owns activation for session ${active.sessionId}`, |
| 3035 | ); |
| 3036 | } |
| 3037 | if (active.activeRuns.has(run.runId) || active.turnToRunId.has(run.turnId)) { |
| 3038 | throw new Error(`Backend generation ${active.generation} already reserved this Run identity`); |
| 3039 | } |
| 3040 | active.activeRuns.set(run.runId, run); |
| 3041 | active.turnToRunId.set(run.turnId, run.runId); |
| 3042 | } |
| 3043 | |
| 3044 | private assertRunCanDispatch(run: AgentRun, backend: AgentBackend): void { |
| 3045 | const active = [...this.backendGenerations.values()].find( |
no test coverage detected