Repository navigation
feat: Report Band tool calls as turn activity #841
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 47 commits into
main
from
feat/python-sdk-report-activity-detail-to-the-platform-producers-INT-1744
Oct 21, 2026
Merged
Changes from all commits
Commits
Show all changes
47 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 3f59acf
feat: Report Band tool calls as turn activity
AlexanderZ-Band 81740a2
refactor: Share the agent-tool method lookup between the turn decorators
AlexanderZ-Band 9a8261b
Merge remote-tracking branch 'origin/main' into feat/python-sdk-repor…
AlexanderZ-Band faea662
fix: Make tool_activity the single owner of what a tool shows
AlexanderZ-Band 770875f
fix: Show slack_send_message as turn activity and tighten activity tests
AlexanderZ-Band 9071d10
Merge the delivery branch into the producers branch
AlexanderZ-Band 429d478
style: Sort the activity kit imports
AlexanderZ-Band 3483221
Merge remote-tracking branch 'origin/main' into the producers branch
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
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
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
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
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,113 @@ | ||
| """What a tool call shows as its turn's activity, and the one place it is reported.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import functools | ||
| import logging | ||
| from collections.abc import AsyncIterator, Awaitable, Callable | ||
| from contextlib import asynccontextmanager | ||
| from contextvars import ContextVar | ||
| from typing import Any | ||
|
|
||
| from band_rest.types.agent_activity_detail import AgentActivityDetail | ||
|
|
||
| from band.runtime.activity import ( | ||
| MEMORY, | ||
| REASONING, | ||
| ActivityObserver, | ||
| activity_observer_of, | ||
| tool_call_activity, | ||
| ) | ||
| from band.runtime.tools.effects import turn_effect | ||
| from band.runtime.tools.registry import ( | ||
| MEMORY_TOOL_NAMES, | ||
| ToolsClass, | ||
| agent_tool_methods, | ||
| ) | ||
| from band.runtime.tools.types import BandTool | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| MEMORY_SAVE_TOOLS = frozenset( | ||
| name for name in MEMORY_TOOL_NAMES if turn_effect(name).did_work | ||
| ) | ||
|
|
||
| # Set while a tool call is shown, so a Band tool another tool calls stays hidden. | ||
| _showing_tool: ContextVar[bool] = ContextVar("band_showing_tool", default=False) | ||
|
|
||
|
|
||
| def tool_detail(name: str) -> AgentActivityDetail: | ||
| """What the room sees while ``name`` runs.""" | ||
| return MEMORY if name in MEMORY_SAVE_TOOLS else tool_call_activity(name) | ||
|
AlexanderZ-Band marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def method_reports_activity(name: str) -> bool: | ||
| """Whether a tools method reports itself; adapters post their own events | ||
| through ``send_event``, so only a model's call to it reports.""" | ||
| return name != BandTool.SEND_EVENT | ||
|
AlexanderZ-Band marked this conversation as resolved.
|
||
|
|
||
|
|
||
| async def _show(observer: ActivityObserver, detail: AgentActivityDetail) -> None: | ||
| """Activity is best-effort: a failed report never changes the tool's outcome.""" | ||
| try: | ||
| await observer.update(detail) | ||
| except Exception: | ||
| logger.warning("Could not report %s activity", detail.kind, exc_info=True) | ||
|
|
||
|
|
||
| @asynccontextmanager | ||
| async def tool_activity(tools: object, name: str) -> AsyncIterator[None]: | ||
| """Show ``name`` as the turn's activity until the tool ends. | ||
|
|
||
| Only the outermost call reports, so a tool that calls other Band tools | ||
| shows as itself throughout. The observer is resolved once so the end lands | ||
| on the turn the tool started on, even if ``tools`` is rebound meanwhile. | ||
| """ | ||
| observer = activity_observer_of(tools) | ||
| if observer is None or _showing_tool.get(): | ||
| yield | ||
| return | ||
| token = _showing_tool.set(True) | ||
| try: | ||
| await _show(observer, tool_detail(name)) | ||
| yield | ||
| finally: | ||
| _showing_tool.reset(token) | ||
| await _show(observer, REASONING) | ||
|
AlexanderZ-Band marked this conversation as resolved.
|
||
|
|
||
|
|
||
| async def _show_on(tools: object, detail: AgentActivityDetail) -> None: | ||
| if observer := activity_observer_of(tools): | ||
| await _show(observer, detail) | ||
|
|
||
|
|
||
| async def report_tool_activity(tools: object, name: str) -> None: | ||
|
AlexanderZ-Band marked this conversation as resolved.
|
||
| """Show ``name`` for a tool whose start and end arrive as separate events.""" | ||
| await _show_on(tools, tool_detail(name)) | ||
|
|
||
|
|
||
| async def end_tool_activity(tools: object) -> None: | ||
| await _show_on(tools, REASONING) | ||
|
|
||
|
|
||
| async def report_memory_activity(tools: object) -> None: | ||
| await _show_on(tools, MEMORY) | ||
|
|
||
|
|
||
| def _observing( | ||
| tool_name: str, method: Callable[..., Awaitable[Any]] | ||
| ) -> Callable[..., Awaitable[Any]]: | ||
| @functools.wraps(method) | ||
| async def observe(self: Any, *args: Any, **kwargs: Any) -> Any: | ||
| async with tool_activity(self, tool_name): | ||
| return await method(self, *args, **kwargs) | ||
|
|
||
| return observe | ||
|
|
||
|
|
||
| def reports_tool_activity(cls: ToolsClass) -> ToolsClass: | ||
| """Report each agent tool method that ``method_reports_activity`` selects.""" | ||
| for definition, method in agent_tool_methods(cls): | ||
| if method_reports_activity(definition.name): | ||
| setattr(cls, definition.method_name, _observing(definition.name, method)) | ||
| return cls | ||
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.