PeaceMaker-best 14c9d44440
feat(runtime): persist tool-progress phase transitions (#5214)
* feat(runtime): persist tool-progress phase transitions

Record bounded warn, block, and recover decisions for lead and task subagent runs while preserving event-loop isolation, fail-open behavior, and concurrent transition order.

* fix(runtime): trust server-owned tool progress attribution

* fix(runtime): centralize trusted audit attribution

* fix(runtime): preserve complete tool progress audit state

* docs: trim tool progress guidance to pass size check

* fix(runtime): fence subagent audit recorder loop

* docs(readme): sync tool-progress event coverage

Signed-off-by: PeaceMaker-best <221849497+PeaceMaker-best@users.noreply.github.com>

---------

Signed-off-by: PeaceMaker-best <221849497+PeaceMaker-best@users.noreply.github.com>
Co-authored-by: PeaceMaker-best <221849497+PeaceMaker-best@users.noreply.github.com>
Co-authored-by: 嗜鵼 <hy2010hy2010@qq.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-09-15 08:45:08 +08:00

30 lines
1.0 KiB
Python

"""Private runtime-context helpers for narrowly scoped audit recorders."""
from typing import Any
LOOP_DETECTION_RECORDER_CONTEXT_KEY = "__run_loop_detection_recorder"
TOOL_PROMOTION_RECORDER_CONTEXT_KEY = "__run_tool_promotion_recorder"
TOOL_PROGRESS_RECORDER_CONTEXT_KEY = "__run_tool_progress_recorder"
def resolve_audit_recorder(
context: object,
*,
recorder_key: str,
) -> tuple[Any | None, bool, str | None]:
"""Resolve a recorder and trusted lead/subagent attribution.
Ordinary lead runs own ``__run_journal``. Task-tool subagents receive only
a server-installed narrow recorder, so its presence is the authority for
subagent attribution; caller-supplied ``is_subagent`` is never consulted.
"""
if not isinstance(context, dict):
return None, False, None
recorder = context.get(recorder_key)
if recorder is not None:
agent_id = context.get("agent_id")
return recorder, True, agent_id if isinstance(agent_id, str) else None
return context.get("__run_journal"), False, None