Repository navigation
feat: deliver compatible serialized activity detail #840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlexanderZ-Band
merged 40 commits into
main
from
feat/python-sdk-report-activity-detail-to-the-platform-delivery-INT-1744
Oct 21, 2026
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
d1419b7
fix: Keep working-state reporting alive through provider turns
AlexanderZ-Band 8ec26b3
fix: Preserve standalone worker binding across tool wrappers
AlexanderZ-Band 1476457
test: Avoid the E2E peer fixture reservation in runtime tests
AlexanderZ-Band 8bfeac0
style: Format the renamed activity platform fixture
AlexanderZ-Band a397d8c
test: Use real time for randomized scheduler grace controls
AlexanderZ-Band 0342d96
feat: Deliver compatible activity detail through the working-state re…
AlexanderZ-Band d76f571
style: Format detail ownership fixture parameters
AlexanderZ-Band 1842638
test: Avoid reserved peer fixtures in activity wire tests
AlexanderZ-Band 06d8124
test: Preserve backlog ordering across valid recovery retries
AlexanderZ-Band 1249060
Merge remote-tracking branch 'origin/main' into feat/python-sdk-repor…
AlexanderZ-Band 1ff4c54
Merge remote-tracking branch 'origin/feat/python-sdk-report-activity-…
AlexanderZ-Band f2ff776
Merge remote-tracking branch 'origin/main' into feat/python-sdk-repor…
AlexanderZ-Band 2f4082e
Merge remote-tracking branch 'origin/feat/python-sdk-report-activity-…
AlexanderZ-Band 650f8d7
Merge remote-tracking branch 'origin/main' into feat/python-sdk-repor…
AlexanderZ-Band 6a62878
refactor: Flatten the activity compatibility retry
AlexanderZ-Band 4a04046
fix: Learn activity detail support from response headers
AlexanderZ-Band eac1fdd
fix: Forward activity detail through the baseline ControlLink
AlexanderZ-Band 9a1430b
refactor: Keep one detail reset and one ownership recheck in the repo…
AlexanderZ-Band 435ae73
test: Scope the recovery-jitter patch to resync's random reference
AlexanderZ-Band 90bc52a
fix: Log a content-free cause when activity detail is downgraded
AlexanderZ-Band 3c665de
refactor: Drop the unreachable cycle token and pin reporter guards
AlexanderZ-Band 2c4a9f7
test: Share one activity-support isolation helper
AlexanderZ-Band 823eeca
Merge upstream main through #838 into the activity delivery branch
7298896
Merge origin/main (#833, #882, #883, #885) into the activity delivery…
AlexanderZ-Band 9d0953d
refactor: Keep activity detail on the turn and send it from the keep-…
AlexanderZ-Band e0541b9
Merge remote-tracking branch 'origin/main' into feat/python-sdk-repor…
AlexanderZ-Band 6860082
refactor: Return early for a missing platform version
AlexanderZ-Band 1faf28b
docs: Describe activity detail and the per-report deadline in reporte…
AlexanderZ-Band 978c0ac
test: Split the activity deadline test and pin the exact deadline
AlexanderZ-Band dfd81ca
test: Prove activity detail through realistic turn flows
AlexanderZ-Band 5037fb9
refactor: Move the activity producers beside the observer they report to
AlexanderZ-Band ec7f54c
test: Share one set of activity report bodies across the activity suites
AlexanderZ-Band 1b98ee9
test: Prove visible activity changes report without waiting for a kee…
AlexanderZ-Band 904dbe8
docs: State that an aborted owner's reports carry no detail
AlexanderZ-Band 9f7d2ea
test: Split the activity detail suite by concern and flush before neg…
AlexanderZ-Band 40843c7
Merge remote-tracking branch 'origin/main' into feat/python-sdk-repor…
AlexanderZ-Band 7b29330
Merge remote-tracking branch 'origin/main' into feat/python-sdk-repor…
AlexanderZ-Band 842935c
Merge branch 'main' into feat/python-sdk-report-activity-detail-to-th…
AlexanderZ-Band a2bb026
test: avoid repeated interpreter startup in CI coverage guard
AlexanderZ-Band 9a8261b
Merge remote-tracking branch 'origin/main' into feat/python-sdk-repor…
AlexanderZ-Band File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| """Process-wide negotiation for optional room activity detail. | ||
|
|
||
| Every agent API response names its version in ``X-API-Version``. Detail is sent | ||
| once any activity response reported a supporting version. A detail rejection on | ||
| any link permanently downgrades every link; boolean liveness remains available. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| import re | ||
| from collections.abc import Mapping | ||
| from threading import Lock | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| # The first agent API that accepts ``activity``; older ones reject it with 422. | ||
| MINIMUM_ACTIVITY_VERSION = (1, 25, 0) | ||
| API_VERSION_HEADER = "x-api-version" | ||
| RELEASE_VERSION = re.compile(r"([0-9]+)\.([0-9]+)\.([0-9]+)") | ||
|
|
||
|
|
||
| def _supports_detail(version: str | None) -> bool: | ||
| if version is None: | ||
| return False | ||
| match = RELEASE_VERSION.fullmatch(version) | ||
| return ( | ||
| match is not None | ||
| and tuple(map(int, match.groups())) >= MINIMUM_ACTIVITY_VERSION | ||
| ) | ||
|
|
||
|
|
||
| class ActivitySupport: | ||
| """Learn detail support from response headers; a rejection latches it off.""" | ||
|
|
||
| def __init__(self) -> None: | ||
| self._lock = Lock() | ||
| self._learned = False | ||
| self._disabled = False | ||
|
|
||
| @property | ||
| def supported(self) -> bool: | ||
| with self._lock: | ||
| return self._learned and not self._disabled | ||
|
|
||
| def observe(self, headers: Mapping[str, str]) -> None: | ||
| version = headers.get(API_VERSION_HEADER) | ||
|
AlexanderZ-Band marked this conversation as resolved.
|
||
| if not _supports_detail(version): | ||
| return | ||
| with self._lock: | ||
| newly_learned = not self._learned | ||
| self._learned = True | ||
| if newly_learned: | ||
| logger.info("Agent API %s supports activity detail", version) | ||
|
|
||
| def disable(self, *, room_id: str) -> None: | ||
| with self._lock: | ||
| already_disabled = self._disabled | ||
| self._disabled = True | ||
| if not already_disabled: | ||
| logger.info( | ||
| "Activity report with detail returned 422 in room %s; " | ||
| "using boolean reporting for this process", | ||
| room_id, | ||
| ) | ||
|
|
||
|
|
||
| activity_support = ActivitySupport() | ||
|
AlexanderZ-Band marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| """Names-only room activity detail, the per-turn state that holds it, and the | ||
| producers a turn reports it through.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from typing import Protocol | ||
|
|
||
| from band_rest.types.agent_activity_detail import AgentActivityDetail | ||
|
|
||
| UNKNOWN_ACTIVITY_TOOL_NAME = "unknown" | ||
| TOOL_CALL = "tool_call" | ||
| REASONING = AgentActivityDetail(kind="reasoning") | ||
| MEMORY = AgentActivityDetail(kind="memory") | ||
| PERMISSION = AgentActivityDetail(kind="permission") | ||
|
|
||
|
|
||
| class ActivityObserver(Protocol): | ||
| async def update(self, activity: AgentActivityDetail) -> None: ... | ||
|
|
||
| async def set_manual_wait(self, waiting: bool) -> None: ... | ||
|
|
||
|
|
||
| def tool_call_activity(name: str | None) -> AgentActivityDetail: | ||
| """The platform requires a name on every ``tool_call`` detail.""" | ||
| return AgentActivityDetail(kind=TOOL_CALL, name=name or UNKNOWN_ACTIVITY_TOOL_NAME) | ||
|
|
||
|
|
||
| def names_only(activity: AgentActivityDetail) -> AgentActivityDetail: | ||
| """Keep only what the room may see: the kind and, for a tool, its name.""" | ||
| if activity.kind == TOOL_CALL: | ||
| return tool_call_activity(activity.name) | ||
| return AgentActivityDetail(kind=activity.kind) | ||
|
|
||
|
|
||
| @dataclass | ||
| class TurnActivity: | ||
| """What one turn is doing; a person's wait overrides its progress.""" | ||
|
|
||
| progress: AgentActivityDetail = REASONING | ||
| waiting: bool = False | ||
|
AlexanderZ-Band marked this conversation as resolved.
|
||
|
|
||
| @property | ||
| def detail(self) -> AgentActivityDetail: | ||
| return PERMISSION if self.waiting else self.progress | ||
|
|
||
| def apply( | ||
| self, | ||
| *, | ||
| activity: AgentActivityDetail | None = None, | ||
| waiting: bool | None = None, | ||
| ) -> None: | ||
| if activity is not None: | ||
| self.progress = names_only(activity) | ||
| if waiting is not None: | ||
| self.waiting = waiting | ||
|
|
||
|
|
||
| def _observer(tools: object) -> ActivityObserver | None: | ||
| return getattr(tools, "_activity_observer", None) | ||
|
|
||
|
|
||
| async def report_tool_activity(tools: object, name: str) -> None: | ||
| if observer := _observer(tools): | ||
| await observer.update(tool_call_activity(name)) | ||
|
|
||
|
|
||
| async def end_tool_activity(tools: object) -> None: | ||
| if observer := _observer(tools): | ||
| await observer.update(REASONING) | ||
|
|
||
|
|
||
| async def report_memory_activity(tools: object) -> None: | ||
| if observer := _observer(tools): | ||
| await observer.update(MEMORY) | ||
|
|
||
|
|
||
| async def set_permission_wait(tools: object, waiting: bool) -> None: | ||
| if observer := _observer(tools): | ||
| await observer.set_manual_wait(waiting) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.