Cross-Agent API Reference¶
Cross-agent communication utilities for Promptise Foundry. Exposes other in-process agents as standard LangChain tools so a primary agent can delegate to them during planning and execution. Supports per-peer ask tools and parallel broadcast to multiple peers.
CrossAgent¶
promptise.cross_agent.CrossAgent
dataclass
¶
Metadata wrapper for a peer agent to be exposed as a tool.
The wrapper is descriptive only. Behavior is implemented by tools produced
via :func:make_cross_agent_tools.
Attributes:
| Name | Type | Description |
|---|---|---|
agent |
Runnable[Any, Any]
|
A runnable agent (e.g., LangGraph or DeepAgents) that accepts
|
description |
str
|
One-line human description used in tool docs to help the calling agent decide when to delegate. |
timeout |
float | None
|
Seconds to wait for this peer's answer. |
Examples:
make_cross_agent_tools¶
promptise.cross_agent.make_cross_agent_tools(peers, *, tool_name_prefix='ask_agent_', include_broadcast=True, caller_identity=None, timeout=None, max_delegation_depth=DEFAULT_MAX_DELEGATION_DEPTH, on_before=None, on_after=None, on_error=None, requires_approval=None)
¶
Create LangChain tools for cross-agent communication.
For each peer, a tool named f"{tool_name_prefix}{peer_name}" is created.
Optionally, a broadcast_to_agents tool is added to fan-out questions to
multiple peers concurrently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peers
|
Mapping[str, CrossAgent]
|
Mapping of peer name → :class: |
required |
tool_name_prefix
|
str
|
Prefix used for each per-peer ask tool. Defaults to
|
'ask_agent_'
|
include_broadcast
|
bool
|
When |
True
|
caller_identity
|
AgentIdentity | None
|
Identity of the delegating agent, announced to peers. |
None
|
timeout
|
float | None
|
Seconds to wait for a peer that sets no
:attr: |
None
|
max_delegation_depth
|
int
|
Most nested delegations allowed in one request
( |
DEFAULT_MAX_DELEGATION_DEPTH
|
on_before
|
ToolHook | None
|
|
None
|
on_after
|
ToolHook | None
|
|
None
|
on_error
|
ToolHook | None
|
|
None
|
requires_approval
|
Callable[[str], bool] | None
|
The approval check of the agent that gets these
tools ( |
None
|
Returns:
| Type | Description |
|---|---|
list[BaseTool]
|
list[BaseTool]: A list of fully constructed tools ready to be appended |
list[BaseTool]
|
to the caller agent’s toolset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
Construction does not contact peers; errors (e.g., network) surface at call time during execution of the generated tools.
Examples: