Skip to content

Breaking: support method and callable-class Activities in Strands Agents activity_as_tool - #402

Merged
campoy merged 7 commits into
mainfrom
fix/strands-agents-activity-tool-class-signature
Nov 4, 2026
Merged

campoy merged 7 commits into
mainfrom
fix/strands-agents-activity-tool-class-signature

Conversation

@campoy

@campoy campoy commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

activity_as_tool in strands_agents now builds the tool from the parameters the Activity is called with:

  • For a callable-class Activity passed as its class, the tool's parameters come from __call__ as an instance binds it (without the receiver of a method, classmethod or functools.partialmethod, with every parameter of a staticmethod), not from the constructor. __call__'s annotations are resolved in its own module. The description is __call__'s own docstring, else the class's (unless dataclasses or namedtuple wrote it), else that of a __call__ it inherits. Only the text before the class docstring's Args section is used, since that section documents the constructor, and a __call__ docstring with only an Args section gets that text in front. The tool keeps the Activity's name.
  • For a method passed as Class.method, a first parameter named self is dropped from the binding, as Breaking: build callable-class activity tools from __call__ and raise ValueError for tools that can't be built in OpenAI Agents #206 and Breaking: support method and callable-class Activities in Deep Agents activity_as_tool #300 do. Strands already left self out of the tool spec, so every call failed with missing a required argument: 'self'.
  • Positional-only parameters bind from the model's input by name; the Activity still gets every argument by position. A class whose __call__ takes positional-only parameters worked on main through its constructor's parameters, so the class change needs this. Function Activities with positional-only parameters, whose calls failed before scheduling on main, now work too.
  • These now raise ValueError when the tool is built:
    • a class whose __call__ is missing or of another kind, can't be read, or takes *args, keyword-only arguments or **kwargs. @activity.defn checks a class's constructor, not its __call__, and the tool passes one argument per parameter, by position;
    • an instance of a callable-class Activity. It raised TypeError from typing.get_type_hints before.
  • Function and bound-method tools are otherwise unchanged.

This is the design of #206 (openai_agents), #300 (deepagents) and #312 (google_adk), with their helpers' code and messages. *args, keyword-only arguments and **kwargs are refused only in a class's __call__: #312 refuses keyword-only arguments and **kwargs there, and #300 refuses all three for every form. *args is refused because Strands makes it a required property that the binding can't take by name. Function and Class.method Activities that take *args or **kwargs fail on main too; refusing them is left for a follow-up. Like #206 and #300, an instance is refused. No public name or option changes.

Breaking change. The change has no version gate: we are not adding version gates to these fixes, and breaking old histories is accepted with the plugins' 1.0 releases.

  • Callers: a callable class passed as its class whose constructor takes the same parameters as __call__ worked, because the model's values happened to reach the right place. If its __call__ also takes a keyword-only parameter, *args or **kwargs, activity_as_tool now raises ValueError. If it takes an optional parameter whose type has no JSON schema, such as client: Client | None = None, Strands now fails to build the tool spec (PydanticSchemaGenerationError). In a Workflow, both fail the Workflow Task. Change __call__, or wrap it in a function Activity with the same name, in the same deployment as the upgrade.
  • Callers, by decision (these stay out of this fix):
    • A function Activity, or a staticmethod passed as Class.method, whose first parameter is named self and has a default worked with that default. The tool now drops self by name, so the model's first argument reaches self. Rename the parameter.
    • A class whose __call__ takes _-prefixed parameter names, or forward references such as List["Parcel"], worked only because the tool used the constructor's annotations. Strands now fails to build the tool spec, as it does for a function with those parameters. Rename the parameters, or write the type itself instead of a string.
    • Parameters named agent or cls, or self in a staticmethod __call__, stay unsupported, as in Strands' own @tool, which leaves these names out of the spec.
  • Replay: runs recorded before this change whose model called a Class.method tool, or a callable-class tool whose constructor parameters differ from __call__'s, fail replay with [TMPRL1100]. Rolling back fails the same kinds of runs recorded on this change, and runs whose model filled a parameter only __call__ has. The method call failed before scheduling an Activity and now schedules one; the class call's recorded arguments, the constructor's, no longer bind, and a class call with __call__'s arguments, which failed before scheduling, now schedules. Likewise, a call that failed before scheduling because a parameter was positional-only now schedules its Activity. Let those runs finish before upgrading, or keep them on the old version with Worker Versioning.

Why?

See #278. activity_as_tool read inspect.signature of the object it was given. A callable class passed as its class offered the model its constructor's parameters, and their values reached __call__: with a one-string constructor and a one-string call, the run completed with a wrong result and no error. A method passed as Class.method failed every call before its Activity was scheduled.

Checklist

  1. Part of [Bug] deepagents, google_adk, google_genai, strands_agents: activity_as_tool builds a callable-class Activity's tool from its constructor #278: this fixes its strands_agents part. deepagents and google_adk are fixed; google_genai has its own PR.

  2. How was this tested:

    • test_tool now also gives the agent a callable class (TrackParcel(carrier) with __call__(parcel_id)) passed as its class, a method passed as Class.method, a class whose __call__ takes positional-only parameters (parcel_id, carrier="road", /, with a constructor taking parcel_id), a class whose __call__ is a classmethod, and a function with a positional-only parameter. It checks each tool's offered and required properties and description, and each Activity's arguments and result from the history. It also builds tools for a class with a constructor-documenting class docstring and an Args-only __call__ docstring, an undocumented dataclass that inherits a documented __call__, a class whose __doc__ isn't a string, a staticmethod __call__, a positional partialmethod __call__, and a class in a postponed-annotations module whose __call__ takes a dataclass defined there. On main the class and method Activities, and the ship_parcel call that adds carrier, are not scheduled (At index 6 diff: 'invoke_model' != 'track_parcel'). On this PR's first revision (e918c4e) neither ship_parcel call is scheduled (At index 10 diff: 'invoke_model' != 'ship_parcel'). On 7714e96, the Args-only class is described by its name and the non-string __doc__ raises AttributeError.
    • test_activity_as_tool_refuses checks the ValueError for __call__ with a keyword-only parameter, *args and **kwargs, for a class without __call__, for a partialmethod that binds by keyword, and for an instance. On main the three __call__ classes build a tool, and the instance raises TypeError (on Python 3.14, or with class-level annotations, AttributeError from Strands).
    • make lint and make test pass locally in Docker with Python 3.13 (230 passed).
    • Replay, with the SDK's Replayer: Workers with no Workflow cache recorded, on main and on this branch, a finished run and a run held between two agent turns for five tools: a function, a callable class whose constructor takes the same parameter as __call__, a method, a callable class whose constructor differs, and a class whose __call__ takes positional-only parameters. The scripted model fills the offered schema.
      • Each version replays its own 10 histories. This branch also replays the 8 histories recorded on e918c4e.
      • main histories on this branch: the method ones fail with [TMPRL1100] ... scheduled event 'invoke_model' does not match activity type of activity command 'shipping-track', the class ones with ... 'shipping-quote' does not match ... 'invoke_model'; the function, matching-class and positional-only ones replay.
      • This branch's histories on main (the rollback target): the method and class ones fail with [TMPRL1100], and so do the positional-only ones, whose model filled carrier, which main doesn't offer; the others replay.
      • A control that starts each run with a timer fails all 20 with [TMPRL1100].
      • Held function runs complete when carried in either direction and to a replacement Worker. Held class runs complete on a replacement Worker and stop with [TMPRL1100] when carried in either direction. A held positional-only run completes on a replacement Worker and when carried from main to this branch, and stops with [TMPRL1100] when carried back to main.
    • The issue's reproduction offers ['parcel_id'] for the class with this change (['carrier'] on main). The defect's end-to-end reproduction, with a scripted model: on main and on 0.1.0 the class tool sent the model's carrier value as parcel_id, the method tool scheduled nothing, a class whose constructor takes a client object failed its Workflow Task, and one with a two-string constructor failed every attempt; with this change all four complete with the model's parcel_id.
  3. Any docs updates needed? The README's Tools section now covers the method and class forms, the refusals and the replay break, and the activity_as_tool docstring names the accepted forms and the ValueErrors.

Decisions:

…nts activity_as_tool

activity_as_tool built the tool from inspect.signature of the object it was
given. A callable-class Activity passed as its class offered the model its
constructor's parameters, whose values reached __call__, and a method passed
as Class.method failed every call because the binding kept self.

Build a class's tool from __call__ as an instance binds it, with __call__'s
types and docstring, and drop a first self parameter from the binding.
Raise ValueError for a class whose __call__ can't be used or takes *args,
keyword-only arguments or **kwargs, and for a callable-class instance.

Breaking: classes whose constructor matched __call__ and whose __call__
takes such parameters, or a parameter with no JSON schema, now fail when the
tool is built. Runs recorded before this change that called a Class.method
tool, or a class tool whose constructor differs from __call__, fail replay.

Part of #278
Drop the staticmethod self lookup, the tool spec layer for agent, cls,
underscore-prefixed names and forward references, and the pydantic
dependency, by decision on #402. Drop self by name, as #206 and #300 do,
and keep positional-only binding, which the class change needs.
@campoy

campoy commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Scope decision for this PR: keep it to the minimal fix. Dropped on purpose, so please don't re-add them in later rounds:

The cases those handled are listed as Caller-breaking by decision in the PR body. agent and cls stay unsupported, as in Strands' own @tool. Positional-only binding stays: the class change needs it.

@campoy
campoy marked this pull request as ready for review November 4, 2026 00:05
@campoy
campoy requested a review from a team as a code owner November 4, 2026 00:05

@DABH DABH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at head 7714e96 (six commits on 9d6f9ff; main has not touched python/strands_agents since, and the branch merges cleanly with main at 52bcb2b). On a worktree at the head, make lint is clean and make test passes 228 of 228 on Python 3.14.3 and on 3.10.20 (temporalio 1.34.0, strands-agents 1.56.0); CI is green on all four cells. I compared main's and the head's activity_as_tool by probe on 3.10 and 3.14 over about 100 function, method and class shapes, including what the Worker's registered instance or bound method then receives. I also recorded nine runs with real Workers on the pinned dev server on each build and replayed each build's histories on the other, ran the head's new tests against main's build, and ran ten one-line mutations of _temporal_activity_tool.py against the tool tests. Every finding below was reproduced. Checked and fine: self: Self under from __future__ import annotations, on a method and on __call__, and self: T, on 3.10 (with typing_extensions.Self) and 3.14; the staticmethod, classmethod and positional partialmethod forms of __call__, and a partialmethod that binds by keyword is refused with the sentence that names it; instances are refused with ValueError (main never built one); generated dataclass and namedtuple docstrings are skipped, and library docstrings (abc.ABC, typing.Generic) no longer become the description, as they did on main; dict[str, Any] and Mapping[str, str] parameters on __call__ build and pass the model's object; a PEP 695 __call__[T] with and without postponed annotations on 3.14; a Class.method behind functools.lru_cache or a class-based decorator, and functools.wraps or wrapt on __call__; dataclass and namedtuple class tools built inside the Workflow sandbox; summary= reaches every scheduled Activity unchanged, since nothing shadows it; and on 3.10 the implicit Optional from typing.get_type_hints gives a class tool the same schema Strands gives a function with the same parameter, because Strands reads the resolved hints only for string annotations. Nothing in Strands' runtime (registry, executors, hooks, interrupts, concurrent tools) sees the stand-in, which only builds the spec. The cases your scope comment leaves out (the staticmethod self lookup, agent and cls, _-prefixed names, eager nested forward references) behave as the body lists, and I haven't re-raised them. Not verified: the body's carries of held runs and its replays of e918c4e histories.

Severity: P1 = wrong result or stuck run in realistic use; P2 = correctness or robustness in an edge case; P3 = docs, tests, cleanup.

Replay. The break is the disclosed one, in both directions. Main's histories on the head: a method tool, a positional-only function, and TrackParcel(carrier) called either with the constructor's arguments (main scheduled track_parcel with ["rail"] and the Worker answered parcel rail via acme-post, the #278 wrong result) or with __call__'s (main returned the bind error to the model) fail with [TMPRL1100], for example Activity type of scheduled event 'invoke_model' does not match activity type of activity command 'track_parcel'. A function tool, a class whose constructor and __call__ take the same parameter, and a class tool that was built but never called all replay. A run that only built a class whose __call__ takes a keyword-only argument fails its Workflow Task with the new ValueError, as the Breaking change section says. The head's histories on main fail for the same four shapes and replay for the rest, as the rollback sentence says. The body explains only the constructor-shaped call ('the class call's recorded arguments, the constructor's, no longer bind'). A call with __call__'s arguments, which main failed before scheduling, now schedules, but the drain rule ('whose model called ... a callable-class tool whose constructor parameters differ') already covers it. No version gate, per the stated policy.

Parity with #206, #300 and #312 on main. The class branch is their code: the __get__ binding, the four __call__ forms, the docstring order, the gated 3.14 dataclass check and the partialmethod sentence. The method branch drops self by name, as #206 and #300 do (#312 also checks that the function sits in a class body). Instances are refused, as in #206 and #300 (#312 accepts them by design). Every refusal is a ValueError, which fails the Workflow Task, as in all three: with a real Worker, a run that builds a class whose __call__ takes a keyword-only argument stays open with that Task failure. Three fixes #206 made in its later rounds are missing here, as they are from #300's and #312's copies. Two are inline: the non-string __doc__ check, and the handling of a docstring with no summary, which matters more here because Strands hides an Args: section. The third is skipping the return annotation when resolving __call__'s types. Only a partialmethod __call__ whose return type is imported under TYPE_CHECKING shows it: the head refuses that class as unreadable, while the SDK registers it (arg_types [None]) and an instance call runs. Main built it with no parameters, so nothing that worked breaks. The SDK-side partialmethod limits that #206's docstring states also hold here, unmentioned, as in #300 and #312: the Worker decodes the arguments without types, and an async one is registered as sync before Python 3.13 (is_async is False on 3.10 and 3.12, True on 3.13 and 3.14). One difference is new: *args and **kwargs are refused only in __call__ (inline). On 3.10 there is nothing to match, since #300 and #312 require 3.11+ and here class and function tools get the same schema. TypeScript's activityAsTool takes a registered name and an explicit schema, so it has no class form.

Where the problems cluster: the binding is right for every form the PR names, and the replay break matches the body. What is left sits in the parts copied from the siblings before their later fixes (descriptions, and the *args/**kwargs rule for functions), in tests that pin none of the description or descriptor behaviour, and in the docs.

Approving: there is no P1 or P2, CI is green, and the replay break is the disclosed one in both directions; everything below is non-blocking.

Outside the diff (all P3, non-blocking)

  • python/strands_agents/README.md:389: the Tools section shows only function activities, and nothing a user reads mentions the replay break. Release notes come from commit subjects only (scripts/release/release_tool.py:456), and this README already documents other replay breaks the same way (lines 80, 115, 121, 675 and 677). Two or three sentences would do. Pass a method as Class.method and register the bound method on the Worker, or pass a callable-class activity as its class and register an instance. An instance, or a __call__ that takes *args, keyword-only arguments or **kwargs, raises ValueError, and parameters named agent or cls are not offered. Runs whose model called a method tool, or a class tool whose constructor's parameters differ from __call__'s, fail replay after the upgrade, so let them finish first or use Worker Versioning.
  • PR body, How was this tested: on main the first ship_parcel call (P-3) is scheduled, because ShipParcel's constructor takes parcel_id; only the P-4 call, which adds carrier, fails before scheduling. 'the instance raises TypeError' holds on 3.10 for a class without class-level annotations; on 3.14, or with class-level annotations, main raised AttributeError: 'TrackParcel' object has no attribute '__name__' from Strands.

stand_in.__annotations__ = hints
# __call__'s own docstring, else the class's, else that of a __call__ it
# inherits.
stand_in.__doc__ = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 (non-blocking): the class docstring is applied whole, so an Args:-only __call__ docstring hides the class's description, and a class docstring that documents the constructor describes __call__'s parameters. Strands leaves Args sections out of the description and falls back to func.__name__ (_extract_description_from_docstring in strands/tools/decorator.py). docstring_parser, which supplies the parameter descriptions, reads a leading Args: as the summary and finds no parameters. Probes on 3.10 and 3.14:

  • A class documented 'Track a parcel through the carrier network.' whose __call__(self, parcel_id: str) docstring holds only Args: / parcel_id: The parcel to track. is described as 'ArgsOnlyCall2', and parcel_id as 'Parameter parcel_id'. Main used the class docstring, next to the constructor's schema.
  • A class whose docstring is 'Ship parcels with a fixed carrier.' plus Args: for its constructor's parcel_id and carrier offers __call__(self, parcel_id) with parcel_id described as 'The default parcel used when the activity is constructed.'
  • A class documented only Args: / carrier: ... that inherits a __call__ documented 'Quote shipping for a parcel.' is described as its class name, as on main, although the body's order promises the inherited docstring.

A Strands function tool with an Args:-only docstring is also described by its name, so only the precedence is new; #206 handles the first and third cases. Fix, verified on a patched copy on both versions: have _class_doc return only the text before the class docstring's first Args header (Strands strips args:, arguments:, parameters:, param: and params:), or None if there is none, through a small _description(doc) helper. Then put that text in front of a __call__ docstring that has none of its own:

own = _docstring(_call_function(vars(cls).get("__call__")))
class_doc = _class_doc(cls)  # the text before the class docstring's Args section
if own is not None and class_doc is not None and _description(own) is None:
    own = class_doc + "\n\n" + inspect.cleandoc(own)
stand_in.__doc__ = (
    own
    or class_doc
    or next(filter(None, map(_docstring, map(_call_function, calls))), None)
)

That gives 'Track a parcel through the carrier network.' with parcel_id described as 'The parcel to track.', 'Parameter parcel_id' in the constructor case, and 'Quote shipping for a parcel.' in the inherited case. The other 13 shapes I ran keep their descriptions. A class docstring whose Args: documents __call__'s parameters would lose them; __call__'s own docstring is the place for those.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed in 0981d9d. _class_doc now returns only the text before the class docstring's Args section, and a __call__ docstring with only an Args section gets that text in front. DescribeParcel in test_tool pins your first two cases: it's described as "Track a parcel through the carrier network.", and parcel_id as "The parcel to track.", not the constructor's text. On 7714e96 it was described as DescribeParcel.

def _docstring(fn: Any) -> str | None:
"""Return ``fn``'s docstring, unless it is missing or blank."""
doc = getattr(fn, "__doc__", None) if fn is not None else None
return doc if doc and doc.strip() else None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 (non-blocking, contrived): a class whose __doc__ isn't a string makes _docstring raise a raw AttributeError from Workflow code, where main built the tool. @activity.defn class DocProperty with __doc__ = property(lambda self: "per-instance doc") and an undocumented __call__(self, parcel_id: str) raises AttributeError: 'property' object has no attribute 'strip' on 3.10 and 3.14. That fails the Workflow Task with a raw error instead of the documented ValueError. Main built the tool, because inspect.getdoc ignores a __doc__ that isn't a string. #206 checks isinstance(doc, str) here; #300's and #312's copies don't. Fix: return doc if isinstance(doc, str) and doc.strip() else None, which builds the tool, described as 'DocProperty' (verified).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0981d9d: _docstring now ignores a __doc__ that isn't a string, as #206 does. DocProperty in test_tool builds and is described by its name; on 7714e96 it raised the AttributeError you saw.

# @activity.defn checks the constructor's signature, not __call__'s, so
# __call__ can take *args, keyword-only arguments or **kwargs, which the
# tool can't pass: it sends one argument per parameter, by position.
for p in signature.parameters.values():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 (non-blocking, pre-existing, parity): *args and **kwargs are refused only in __call__, so a function or Class.method activity that takes them still gets a tool that can't work, and the body's parity sentences don't match #312 and #300. The reason in the comment above (one argument per parameter, by position) holds for every form.

  • @activity.defn async def fn_star_args(first: str, *rest: str) builds a tool that offers rest as a required string. A call that fills it fails in stream with got an unexpected keyword argument 'rest', which goes back to the model.
  • fn_kwargs(first: str, **extra: str) offers extra as a required string. {"first": "a"} schedules ["a", {}], because apply_defaults adds the empty dict and stream passes it by position. With a real Worker every attempt fails with fn_kwargs() takes 1 positional argument but 2 were given, and the default retry policy retries it indefinitely.

Both behave this way on main, so neither is a regression. But #300 refuses *args, keyword-only arguments and **kwargs for every form, and #206 refuses **kwargs for every form. The body says 'Like #312, *args, keyword-only arguments and **kwargs are refused only in a class's __call__', but #312 refuses only keyword-only arguments and **kwargs there. It also says 'Like #300, *args is refused too', but #300 refuses it for functions as well. Fix, verified on a patched copy: check params for VAR_POSITIONAL and VAR_KEYWORD in __init__, after the self drop, for every form. Both functions then raise ValueError, and every other shape builds as before (keyword-only parameters can't reach a function, since @activity.defn rejects them). A run that merely builds such a function tool would then fail its Workflow Task, so it needs a line under Breaking change. If you'd rather keep the scope, correct the two parity sentences instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the same reason holds for every form. It fails the same way on main, though, and refusing it for functions and Class.method would widen this PR past the defect, so per the scope decision I'm leaving it for a follow-up. I corrected the two parity sentences in the body: #312 refuses only keyword-only arguments and **kwargs in __call__, and #300 refuses all three for every form.

(["P-7"], "weigh P-7 with WeighParcel"),
]

cases: list[tuple[Callable[..., Any], list[str], list[str]]] = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 (non-blocking, tests): the tests pin the offered properties and the scheduled arguments, but none of the description order, the generated-docstring filter, the staticmethod and partialmethod forms, the refusals for a missing __call__ or for the partialmethod keyword case, or resolving __call__'s types in its own module. With six one-line mutations of _temporal_activity_tool.py applied together, test_tool.py, test_tool_errors.py and test_interrupt_exception.py still pass (12 of 12). The six: no staticmethod unwrapping in _call_function, the generated dataclass docstring kept, the class docstring ahead of __call__'s, stand_in.__annotations__ = {}, include_extras dropped, and the partialmethod sentence removed. Four more, applied together, also leave test_tool.py green (5 of 5): taking the last __call__ in the MRO instead of the first (every test class defines its own), converting positional-only parameters for classes only (the body's positional-only function claim has no test), if func is None and calls: (a class without __call__ then raises IndexError), and narrowing the except Exception around the reflection. Two of the first six matter only under from __future__ import annotations, which no test module uses. With stand_in.__annotations__ = {}, a class whose __call__ takes a module-local dataclass fails with PydanticUserError: ... you should define Parcel. Without include_extras, an Annotated[str, "The city"] parameter loses its description. Smallest additions:

  • tool_spec["description"] assertions for a class with its own __call__ docstring, an undocumented dataclass, and a dataclass that inherits a documented __call__;
  • rows here for a staticmethod __call__, a positional partialmethod (['passengers', 'currency'] for partialmethod(_quote, "SFO")) and a subclass that inherits __call__;
  • a positional-only function in test_tool;
  • a class without __call__ and a keyword-binding partialmethod in test_activity_as_tool_refuses;
  • one class in a small postponed-annotations module whose __call__ takes a dataclass defined there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 0981d9d, as tool-spec rows in test_tool (properties, required and description) plus two refusals:

  • descriptions for the Args-only __call__ docstring with a class description, an undocumented dataclass that inherits a documented __call__ (generated docstring skipped), and a non-string __doc__;
  • a staticmethod __call__, a positional partialmethod (['destination', 'parcel_id']), and the inherited __call__ above;
  • a positional-only function, run through the agent;
  • a class without __call__ and a keyword-binding partialmethod in test_activity_as_tool_refuses;
  • LoadParcels in tests/postponed_activities.py, a postponed-annotations module, whose __call__ takes a dataclass defined there.

I didn't add rows for include_extras, the MRO order or the narrowed except.

Give a __call__ docstring with only an Args section the class's
description, and use only the text before the class docstring's Args
section, which documents the constructor. Ignore a __doc__ that isn't a
string. Pin the description order, the generated-docstring filter, the
staticmethod and partialmethod forms, a positional-only function, the
missing-__call__ and keyword partialmethod refusals, and types resolved
in __call__'s module. Document the class and method forms and the replay
break in the README.
@campoy

campoy commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review. Summary items:

make lint passes and make test gives 230 passed locally on Python 3.13.

@campoy
campoy merged commit a8d445b into main Nov 4, 2026
27 checks passed
@campoy
campoy deleted the fix/strands-agents-activity-tool-class-signature branch November 4, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants