fix: harden run-level hook lifecycle
maintainer edit: keep cancellation out of on_error so shutdown paths do not look like run failures, and let the SDK capture hook use the authoritative after_run snapshot.
This commit is contained in:
1 parent
2ea226055e
commit
8933da1ec5
4 files changed
+93
-2
No files matched your search
@@ -277,7 +277,13 @@ class AgentRunner:
|
||||
try:
|
||||
await hook.before_run(context)
|
||||
result = await self._run_core(spec, hook, messages)
|
||||
except BaseException as exc:
|
||||
except asyncio.CancelledError as exc:
|
||||
context.messages = list(messages)
|
||||
context.stop_reason = "cancelled"
|
||||
context.error = None
|
||||
context.exception = exc
|
||||
raise
|
||||
except Exception as exc:
|
||||
context.messages = list(messages)
|
||||
context.stop_reason = "error"
|
||||
context.error = f"Error: {type(exc).__name__}: {exc}"
|
||||
|
||||
Reference in new issue
Block a user