(
self,
prompt: Any,
*,
label: Optional[str] = None,
phase: Optional[str] = None,
schema: Optional[Mapping[str, Any]] = None,
model: Optional[str] = None,
agent_type: Optional[str] = None,
isolation: Optional[str] = None,
)
| 135 | # ── primitives ─────────────────────────────────────────────────────────── |
| 136 | |
| 137 | async def agent( |
| 138 | self, |
| 139 | prompt: Any, |
| 140 | *, |
| 141 | label: Optional[str] = None, |
| 142 | phase: Optional[str] = None, |
| 143 | schema: Optional[Mapping[str, Any]] = None, |
| 144 | model: Optional[str] = None, |
| 145 | agent_type: Optional[str] = None, |
| 146 | isolation: Optional[str] = None, |
| 147 | ) -> Any: |
| 148 | # Deterministic call-path key (taken synchronously, so it is stable |
| 149 | # across runs regardless of fan-out timing). |
| 150 | key = current_branch().path + (current_branch().next_slot(),) |
| 151 | spec = AgentSpec( |
| 152 | prompt=str(prompt), |
| 153 | label=label, |
| 154 | phase=phase, |
| 155 | schema=schema, |
| 156 | model=model, |
| 157 | agent_type=agent_type, |
| 158 | isolation=isolation, |
| 159 | ) |
| 160 | eff_label = label or agent_type or "agent" |
| 161 | eff_agent_type = agent_type or "general-purpose" |
| 162 | eff_phase = phase or self._progress.current_phase |
| 163 | |
| 164 | key_str = key_to_str(key) |
| 165 | cached = self._journal.lookup(key, spec) |
| 166 | if cached is not MISS: |
| 167 | record = self._progress.agent_started( |
| 168 | self._next_display(), eff_label, eff_phase, key_str, agent_type=eff_agent_type |
| 169 | ) |
| 170 | self._progress.agent_finished(record, status="cached") |
| 171 | return cached |
| 172 | |
| 173 | # Live calls only: count toward the per-run cap and the budget ceiling. |
| 174 | self._controller.signal.throw_if_aborted() |
| 175 | self._scheduler.reserve() |
| 176 | self._budget.check() |
| 177 | |
| 178 | record = self._progress.agent_started( |
| 179 | self._next_display(), eff_label, eff_phase, key_str, agent_type=eff_agent_type |
| 180 | ) |
| 181 | attempts = 0 |
| 182 | while True: |
| 183 | child = create_child_abort_controller(self._controller) |
| 184 | self._agent_controllers[key_str] = child |
| 185 | try: |
| 186 | async with self._scheduler.slot(): |
| 187 | try: |
| 188 | outcome = await self._runner.run(spec, abort=child, index=key_str) |
| 189 | except AbortError: |
| 190 | outcome = AgentOutcome(skipped=True) |
| 191 | except Exception as exc: # noqa: BLE001 — a subagent death -> None |
| 192 | outcome = AgentOutcome(error=f"{type(exc).__name__}: {exc}") |
| 193 | finally: |
| 194 | self._agent_controllers.pop(key_str, None) |
nothing calls this directly
no test coverage detected