teams
strands_teams.teams ¶
Generic team-dispatch and artifact tools for the coordinator agent (Wave C).
These five @tool functions are the domain-agnostic port of the pre-split code-context team-tools module. They carry ONLY generic mechanics in their docstrings — all domain guidance (team sizing, tool subsets, artifact sections) lives in the coordinator system prompt composed by :mod:strands_teams.coordinator, never here, because tool docstrings cannot vary per use case (packet §4).
Every tool reads its per-run state (layout, tool registry, node model config, timeouts, rubric) from tool_context.invocation_state rather than module-level globals (AC-8-4; research-strands.yaml §ToolContext). There is deliberately no configure() module setter and no mutable module state.
dispatch_team runs a team as a native strands :class:~strands.multiagent.Swarm of freshly constructed Agent nodes, each with its own explicit BedrockModel (AC-8-1, AC-8-2), and awaits swarm.invoke_async (AC-8-1). Repetitive-handoff detection is set to window 8 / min-unique 3 to preserve ping-pong detection (AC-8-3; research-strands.yaml caveat).
TEAM_TOOLS module-attribute ¶
TEAM_TOOLS = (
dispatch_team,
read_team_findings,
write_artifact,
score_narrative,
enrich_artifact,
)
The five coordinator team tools, in canonical order (consumed by the factory).
TeamInvocationState ¶
Bases: TypedDict
Shared state propagated to every coordinator tool via invocation_state.
Built by the coordinator factory (:mod:strands_teams.coordinator) and passed to coordinator.invoke_async(prompt, invocation_state=...) by the runner, which strands forwards to each tool's tool_context.invocation_state. This replaces the pre-split module-level _output_dir / _repo_path / _tool_registry globals (AC-8-4).
Keys
layout: The run's :class:~strands_teams.layout.TeamsLayout (all paths). tool_registry: Map of tool name -> tool object, for resolving the string tool names in team-agent specs to real tool objects. node_model_config: Kwargs passed to BedrockModel(**config) when constructing each fresh team-agent node. execution_timeout: Default max seconds for an entire team swarm. node_timeout: Default max seconds per agent node within a team. use_case_name: The active use case's name (for logging/debug). rubric: The :class:~strands_teams.rubric.NarrativeRubric used by score_narrative. authority: The active team's :class:~strands_teams.models.AuthorityGrant (what it may do). Present only inside a dispatched team's swarm invocation_state; the coordinator's own state omits it. Treat it as a read-only shared reference — never mutate it from within a concurrently-executing node tool (AC-5-3; research-coding-runtimes.yaml strands_tool_pattern lines 20-22, 30). budget: The active team's :class:~strands_teams.models.Budget (how much it may spend). Same read-only, dispatched-team-only contract as authority. acceptance_criteria: The acceptance criteria the active team must satisfy. input_revisions: Opaque revision-identifier strings the team should build on (resolved to Phase-4 ArtifactRevision objects in a later phase; treated as opaque strings here — AC-2-7).
dispatch_team async ¶
dispatch_team(
team_id,
mandate,
agents,
tool_context,
file_scope=None,
key_questions=None,
artifact_pointers=None,
acceptance_criteria=None,
authority=None,
budget=None,
input_revisions=None,
max_handoffs=10,
execution_timeout=None,
node_timeout=None,
)
Dispatch a specialist team to investigate one area and persist its findings.
Each team runs as a native Strands Swarm — a group of agents that hand off to one another to complete a mandate. The team's task is automatically augmented with a Required-Output block instructing the last agent to write its findings and metadata files (paths are supplied in the augmented task). A confined write_file tool is auto-added to every agent.
TASK CONTRACT — a team is dispatched under a typed authority + budget contract: - authority grants capabilities. A team whose grant has may_create_blocking_finding false CANNOT persist a blocking finding: this tool strips any such finding from the team's typed findings and returns an error. Enforcement is in this tool's code, not the agents' prompts. Omit authority to permit blocking findings (legacy behavior). - budget bounds resources. A positive max_wall_clock_minutes sets the swarm's execution timeout to max_wall_clock_minutes * 60. - acceptance_criteria are the conditions the team must satisfy; they are surfaced in the team task AND checked for coverage by the quality hook. - input_revisions are opaque revision-id strings the team builds on.
AGENT SPEC FORMAT — each entry in agents is a dict with: - name (str): unique node name (e.g. "analyst", "reader"). - system_prompt (str): role and instructions for this agent. - tools (list[str]): tool names for this agent, resolved from the coordinator's tool registry. Unknown names are dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team_id | str | Unique team identifier (e.g. | required |
mandate | str | What to investigate and why (1-3 sentences). | required |
agents | list[dict[str, Any]] | List of agent spec dicts (see AGENT SPEC FORMAT). | required |
tool_context | ToolContext | Framework-injected run context (invocation state). | required |
file_scope | list[str] | None | Optional file paths or directories to focus on. | None |
key_questions | list[str] | None | Optional questions the team should answer. | None |
artifact_pointers | list[str] | None | Optional pre-computed artifact paths to consult. | None |
acceptance_criteria | list[str] | None | Optional conditions the team's output must satisfy. | None |
authority | dict[str, Any] | None | Optional capability grant as a JSON dict with any of | None |
budget | dict[str, Any] | None | Optional resource envelope as a JSON dict with any of | None |
input_revisions | list[str] | None | Optional opaque revision-id strings the team builds on. | None |
max_handoffs | int | Max handoffs (and iterations) within the team. | 10 |
execution_timeout | float | None | Max seconds for the entire team. Omit for the run default. | None |
node_timeout | float | None | Max seconds per agent turn. Omit for the run default. | None |
Returns:
| Type | Description |
|---|---|
str | JSON with |
str |
|
str | rejected forbidden blocking finding — |
str |
|
Source code in packages/strands-teams/src/strands_teams/teams.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | |
read_team_findings ¶
Read findings from dispatched teams.
If team_id is None, lists all team directories with their status, metadata summary, and whether typed findings are present — use this to see which teams have completed. If team_id is given, returns that team's typed findings.json (parsed) when it exists and validates, AND the human findings.md narrative alongside it; when the typed sidecar is absent or invalid it falls back to the raw findings.md markdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_context | ToolContext | Framework-injected run context (invocation state). | required |
team_id | str | None | Specific team to read, or | None |
Returns:
| Name | Type | Description |
|---|---|---|
str | JSON listing all teams (when | |
str | content (when a | |
str | list of finding objects, | |
str | any blocking finding lacking evidence, | |
str | human | |
file | str | line prose, structured sections) when the file exists — this markdown |
str | is the rich input for bundle synthesis. For a fallback read, | |
str | is the markdown string and |
Source code in packages/strands-teams/src/strands_teams/teams.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 | |
write_artifact ¶
Write a per-area narrative artifact or the top-level executive summary.
All artifact paths come from the run's layout. Diagrams must use mermaid code-fenced blocks (never ASCII art). The artifact section structure the coordinator should follow is described in its system prompt, not here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area | str | Artifact area identifier (e.g. | required |
content | str | The full markdown content to write. | required |
tool_context | ToolContext | Framework-injected run context (invocation state). | required |
is_executive_summary | bool | If True, write the executive summary instead of a per-area artifact. | False |
Returns:
| Type | Description |
|---|---|
str | JSON with |
Source code in packages/strands-teams/src/strands_teams/teams.py
score_narrative ¶
Score a per-area artifact's quality using the run's rubric.
Call after write_artifact to evaluate quality. If needs_revision is True (total below the rubric's revision threshold), call enrich_artifact and rewrite via write_artifact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area | str | The artifact area to score (e.g. | required |
tool_context | ToolContext | Framework-injected run context (invocation state). | required |
Returns:
| Type | Description |
|---|---|
str | JSON with |
str | average, the |
Source code in packages/strands-teams/src/strands_teams/teams.py
enrich_artifact ¶
Read an existing artifact and prepare enrichment context.
Call when score_narrative reports needs_revision. Returns the current artifact content plus the feedback so you can rewrite it with improvements via write_artifact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area | str | The artifact area to enrich (e.g. | required |
feedback | str | Specific feedback from | required |
tool_context | ToolContext | Framework-injected run context (invocation state). | required |
Returns:
| Type | Description |
|---|---|
str | JSON with the current artifact |
str |
|