Create a child Context for the node, inheriting from parent. If prior_output or prior_interrupt_ids were provided at construction (resume scenario), pre-populates ctx with state from the previous run.
(
self,
resume_inputs: dict[str, Any] | None,
attempt_count: int = 1,
)
| 188 | return True |
| 189 | |
| 190 | def _create_child_context( |
| 191 | self, |
| 192 | resume_inputs: dict[str, Any] | None, |
| 193 | attempt_count: int = 1, |
| 194 | ) -> Context: |
| 195 | """Create a child Context for the node, inheriting from parent. |
| 196 | |
| 197 | If prior_output or prior_interrupt_ids were provided at |
| 198 | construction (resume scenario), pre-populates ctx with state |
| 199 | from the previous run. |
| 200 | """ |
| 201 | from ..agents.context import Context |
| 202 | |
| 203 | ic = self._parent_ctx._invocation_context |
| 204 | base_branch = ( |
| 205 | self._override_branch |
| 206 | if self._override_branch is not None |
| 207 | else ic.branch |
| 208 | ) |
| 209 | |
| 210 | if self._use_sub_branch: |
| 211 | segment = f"{self._node.name}@{self._run_id}" |
| 212 | branch = f"{base_branch}.{segment}" if base_branch else segment |
| 213 | ic = ic.model_copy(update={"branch": branch}) |
| 214 | elif self._override_branch is not None: |
| 215 | ic = ic.model_copy(update={"branch": self._override_branch}) |
| 216 | else: |
| 217 | ic = ic.model_copy() |
| 218 | |
| 219 | ctx = Context( |
| 220 | ic, |
| 221 | parent_ctx=self._parent_ctx, |
| 222 | node=self._node, |
| 223 | run_id=self._run_id, |
| 224 | resume_inputs=resume_inputs, |
| 225 | use_as_output=self._use_as_output, |
| 226 | attempt_count=attempt_count, |
| 227 | ) |
| 228 | |
| 229 | # override the inherited isolation_scope when explicitly set. |
| 230 | if self._override_isolation_scope is not None: |
| 231 | ctx.isolation_scope = self._override_isolation_scope |
| 232 | |
| 233 | # Carry forward state from a previous run (resume scenario). |
| 234 | if self._prior_output is not None: |
| 235 | ctx._output_value = self._prior_output |
| 236 | ctx._output_emitted = True |
| 237 | if self._prior_interrupt_ids: |
| 238 | ctx._interrupt_ids.update(self._prior_interrupt_ids) |
| 239 | |
| 240 | return ctx |
| 241 | |
| 242 | async def _execute_node( |
| 243 | self, |
no test coverage detected