datamongus
08/28/2025, 12:45 AMfrom marvin import Agent, Team
from dataclasses import dataclass, field
from typing import Any
@dataclass(kw_only=True)
class HierarchicalTeam(Team):
"""A team with a leader who delegates to specialists."""
leader: Agent = field(repr=False)
specialists: list[Agent] = field(repr=False)
def __post_init__(self):
self.members = [self.leader] + self.specialists
self.active_member = self.leader
self.delegates = {self.leader: self.specialists}
# Usage
leader = Agent(name="Project Manager", instructions="Coordinate the team and make final decisions")
specialists = [
Agent(name="Designer", instructions="Create visual designs"),
Agent(name="Developer", instructions="Implement technical solutions")
]
team = HierarchicalTeam(leader=leader, specialists=specialists)
result = team.run("Create a landing page for our product")
error
INFO | prefect.src.bots.jarvis.api - Agent response: I encountered an error while processing your request: HierarchicalTeam.__init__() missing 1 required positional argument: 'members'
Marvin
08/28/2025, 12:45 AMMarvin
08/28/2025, 12:46 AM<your code or error here>
To help me diagnose quickly, please share:
- Link to the doc/example you’re using
- Your Prefect version (prefect version
)
- Python version and OS
- How you’re running it (e.g., python script.py
, prefect deploy
, or flow.from_source(...).deploy(...)
)
Note: If the example you’re using is from Prefect 2.x, some APIs were removed in Prefect 3.x and will fail, for example:
- Deployment.build_from_flow()
was removed; use flow.from_source(...).deploy(...)
instead
- prefect deployment build
CLI command was removed; use prefect deploy
instead
- GitHub storage blocks were replaced by .from_source('<https://github.com/owner/repo>')
Once I have the link and the error, I’ll pinpoint the fix or provide the corrected code.Marvin
08/28/2025, 12:46 AMMarvin
08/28/2025, 12:50 AMTeam
is a dataclass that requires a members
argument. Your subclass doesn’t provide it, so the auto-generated __init__
still expects members
.
Two easy fixes:
1) Quick fix: pass members
when you construct the team
leader = Agent(name="Project Manager", instructions="Coordinate the team and make final decisions")
specialists = [
Agent(name="Designer", instructions="Create visual designs"),
Agent(name="Developer", instructions="Implement technical solutions"),
]
team = HierarchicalTeam(
members=[leader] + specialists, # <-- add this
leader=leader,
specialists=specialists,
)
result = team.run("Create a landing page for our product")
2) Compute members
in your subclass (no need to pass it)
- Override the members
field to exclude it from __init__
, then set it in __post_init__
.
- Call super().__post_init__()
so Team
can finish its own setup.
from marvin import Agent, Team
from dataclasses import dataclass, field
@dataclass(kw_only=True)
class HierarchicalTeam(Team):
"""A team with a leader who delegates to specialists."""
leader: Agent = field(repr=False)
specialists: list[Agent] = field(repr=False)
# Override base field so it's not required in __init__
members: list[Agent] = field(init=False, repr=False, default_factory=list)
def __post_init__(self):
self.members = [self.leader] + self.specialists
self.delegates = {self.leader: self.specialists}
# Let Team finalize any internal setup
super().__post_init__()
# Usage
leader = Agent(name="Project Manager", instructions="Coordinate the team and make final decisions")
specialists = [
Agent(name="Designer", instructions="Create visual designs"),
Agent(name="Developer", instructions="Implement technical solutions"),
]
team = HierarchicalTeam(leader=leader, specialists=specialists)
result = team.run("Create a landing page for our product")
If this example came directly from the docs, it looks like the missing members
requirement is a docs bug. I’m happy to file a docs fix once you confirm the page you used.
References:
- Teams concept
- Team APIdatamongus
08/28/2025, 12:52 AMMarvin
08/28/2025, 12:52 AMMarvin
08/28/2025, 12:52 AMTeam
is a dataclass that requires the members
field at init time. Here’s your example fixed by overriding members
so it’s computed in __post_init__
and not required in `__init__`:
from marvin import Agent, Team
from dataclasses import dataclass, field
@dataclass(kw_only=True)
class HierarchicalTeam(Team):
"""A team with a leader who delegates to specialists."""
leader: Agent = field(repr=False)
specialists: list[Agent] = field(repr=False)
# Make 'members' not required in __init__; we'll compute it in __post_init__
members: list[Agent] = field(init=False, repr=False, default_factory=list)
def __post_init__(self):
# Build members from the leader and specialists
self.members = [self.leader] + self.specialists
# Optionally set up delegation structure
self.delegates = {self.leader: self.specialists}
# Let Team perform its normal initialization
super().__post_init__()
# Usage
leader = Agent(name="Project Manager", instructions="Coordinate the team and make final decisions")
specialists = [
Agent(name="Designer", instructions="Create visual designs"),
Agent(name="Developer", instructions="Implement technical solutions"),
]
team = HierarchicalTeam(leader=leader, specialists=specialists)
result = team.run("Create a landing page for our product")
print(result)
If this came from the docs, it’s missing that members
override. For reference:
- Teams concept
- Team APIdatamongus
08/28/2025, 12:53 AMMarvin
08/28/2025, 12:53 AMMarvin
08/28/2025, 12:53 AMmembers
override, which makes Team.__init__
require members
. Here’s the same example fixed so it runs as-is:
from marvin import Agent, Team
from dataclasses import dataclass, field
@dataclass(kw_only=True)
class HierarchicalTeam(Team):
"""A team with a leader who delegates to specialists."""
leader: Agent = field(repr=False)
specialists: list[Agent] = field(repr=False)
# 'Team' requires 'members' at init — mark it init=False and compute it here
members: list[Agent] = field(init=False, repr=False, default_factory=list)
def __post_init__(self):
# Build team composition
self.members = [self.leader] + self.specialists
self.active_member = self.leader
self.delegates = {self.leader: self.specialists}
# Let Team do its normal post-init
super().__post_init__()
# Usage
leader = Agent(name="Project Manager", instructions="Coordinate the team and make final decisions")
specialists = [
Agent(name="Designer", instructions="Create visual designs"),
Agent(name="Developer", instructions="Implement technical solutions"),
]
team = HierarchicalTeam(leader=leader, specialists=specialists)
result = team.run("Create a landing page for our product")
print(result)
I’ll open a docs fix to update the example on the Teams page so others don’t hit this. For reference:
- Teams concept docs
- Team API reference
If you’d like, I can tag you on the PR/issue — just share your GitHub handle.