You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add scenarios from NegotiationArena
* [autofix.ci] apply automated fixes
* Refactor negotiation arena examples and update .gitignore
Refactored negotiation arena example scripts to use more explicit typing, improved agent profile retrieval logic, and removed unused OpenAI API key loading. Updated .gitignore to exclude negotiation_arena redis-data directory.
* Fix Mypy type errors in negotiation arena files
* Modify error handling and update readme
* Add multi-agent support for 3+ agents
* Add multi-agent test suite with documentation and examples
* Fix unused variable in evaluators
* Unify classes for all agent scenarios
Remove separation between 2-agent and multi-agent cases by consolidating duplicate classes and logic paths into unified implementations
* Support private messages (WIP)
* Add example of multi-agent private message
* Add field `to` for private messages
* Improve private message example
* Don't use special `private_message` action type, use `to` for all types
* change made on PM framework. check out envs/parallel.py for updates
* Remove manual backup of `envs/parallel.py`
* Remove unused `_actions_to_natural_language`
* Format with ruff
* Add README for `multi_agents_private_dm` example
* Fix typo in `test_rule_based_terminated_evaluator`
* changes in dm
* [autofix.ci] apply automated fixes
* Fix typing
* Remove commented code
* Make mypy happy
* Debug evaluator not collecting all agents' evaluation
* Try fix evaluator
* Make mypy happy
* [autofix.ci] apply automated fixes
* Update uv lock
* Remove debug prints
* Clean up evaluator agent counting
* [autofix.ci] apply automated fixes
* Format with ruff
* fixup! Clean up evaluator agent counting
* Remove unnecessary git ignores
* Remove private inbox, handle DM in observation creation
* Remove extraneous comments
* Remove changes under `examples/experimental/multi_agent_tests` from Keyu
* Add negotiation arena test
* Remove unused method
* Remove some comments to reduce diff
* Reduce diffs
* Simplify README
* Fix breaking change in `to_natural_language()`
* Fix typo
* Make `to` instructions clearer in system prompt
* Remove trick in evaluator
* Validate `to` field
* Make `to` error more detailed
* Add test for private messages
* Add test for invalid message recipients
* Use multi-agents in private message routing test
* Use pydantic field validator to check and filter `to` field in actions
* Remove private message specific hints in general prompt
* Fix action type in sampled actions being int instead of str literal
* Clean up parallel env tests
* [autofix.ci] apply automated fixes
* Validate instead of filtering `to` field in agent actions
* Regenerate when `to` field contains invalid names
* [autofix.ci] apply automated fixes
* Avoid unnecessary comment change
* Add tests to ensure private message is not visible to non-recipients
* Include private message `to` info in `AgentAction.to_natural_language()`
* merging docs
* modify pytest
---------
Co-authored-by: Keyu(Frank) He <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: rcwang937 <[email protected]>
Co-authored-by: Xuhui Zhou <[email protected]>
Copy file name to clipboardExpand all lines: docs/pages/concepts/agents.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,29 @@
3
3
Agent is a concept in Sotopia to represent decision-making entities that can interact with each other in a social environment. Agents can be human participants, AI models, or other entities. No matter which type of agent, they have the same interface to interact with the environment: the input is an [`Observation`](/python_API/messages/message_classes#observation) and the output is an [`AgentAction`](/python_API/messages/message_classes#agentaction), each of which is a subclass of [`Message`](/python_API/messages/message_classes#message). You can think of the environment and the agents are sending messages to each other, while the message from the environment is the observation for the agents, and the message from each of the agents is the action that they want to take in the environment. In Sotopia, we are simulating the interaction between agents with social roles, which includes both human characters and various AI assistants, which are defined as profiles [`AgentProfile`](/python_API/database/persistant_profile#agentprofile-class).
4
4
5
5
### Actions of agents
6
-
The types of action is defined by the `ActionType` type alias, which is a literal type that can only take one of the following values: `none`, `speak`, `non-verbal communication`, `action`, `leave`. An agent can choose to n perform physical actions (`action`), use language (`speak`) or gestures or facial expressions (`non-verbal communication`) to communicate, or choose to do nothing (`none`), or leave the interaction (`leave`).
6
+
The types of action is defined by the `ActionType` type alias, which is a literal type that can only take one of the following values: `none`, `speak`, `non-verbal communication`, `action`, `leave`. An agent can choose to perform physical actions (`action`), use language (`speak`) or gestures or facial expressions (`non-verbal communication`) to communicate, or choose to do nothing (`none`), or leave the interaction (`leave`).
7
7
8
8
Apart from the type of action, the content of the action, e.g. the utterance, the concrete action, etc., is a free-form string in the `argument` attribute of the `AgentAction` class.
9
9
10
+
#### Private Messages
11
+
Agents can send private messages to specific recipients using the `to` field in `AgentAction`. When an action includes a `to` field with a list of recipient agent names:
12
+
- The action is only visible to the sender and the specified recipients
13
+
- Other agents will not see the private message in their observations
14
+
- This enables private conversations, secret planning, and side-channel communication in multi-agent scenarios
# Private message (visible only to sender and "agent2")
22
+
private_action = AgentAction(
23
+
action_type="speak",
24
+
argument="Psst, let's discuss this privately",
25
+
to=["agent2"]
26
+
)
27
+
```
28
+
10
29
### Profiles of agents
11
30
The profiles of agents are passed in as either of two argument of [the constructor of agents](/python_API/agents/base_agent_api_docs#constructor): `uuid_str` or `agent_profile`. The `uuid_str` is used together with the Redis database to retrieve an agent profile, while the `agent_profile` is a Pydantic `AgentProfile` object.
12
31
We strong recommend to use `uuid_str`, as it can more easily be used with other sotopia tools.
@@ -28,5 +47,5 @@ from sotopia.messages.message_classes import AgentAction, Observation
Copy file name to clipboardExpand all lines: docs/pages/examples/examples.mdx
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,3 +19,35 @@ python examples/benchmark_evaluator.py --push-to-db --model=<the model used to b
19
19
20
20
## Example 2: Generate script-like episodes
21
21
See `docs/simulation_modes.md`for more information.
22
+
23
+
## Example 3: Multi-Agent Private Messages
24
+
Sotopia supports private messaging between agents, allowing agents to send messages that are only visible to specific recipients. This enables private conversations, secret planning, and side-channel communication in multi-agent scenarios.
25
+
26
+
See `examples/experimental/multi_agents_private_dm/README.md`for more information and example scripts.
27
+
28
+
### Quick Example
29
+
```python
30
+
from sotopia.messages import AgentAction
31
+
from sotopia.envs import ParallelSotopiaEnv
32
+
33
+
# Create actions with private messages
34
+
actions = {
35
+
"agent1": AgentAction(
36
+
action_type="speak",
37
+
argument="Psst, agent2, let's discuss this privately",
38
+
to=["agent2"] # Only visible to agent1 and agent2
39
+
),
40
+
"agent2": AgentAction(
41
+
action_type="speak",
42
+
argument="Hello everyone!"# Public message, visible to all
43
+
),
44
+
"agent3": AgentAction(
45
+
action_type="speak",
46
+
argument="I'll talk to agent1",
47
+
to=["agent1"] # Only visible to agent1 and agent3
48
+
),
49
+
}
50
+
51
+
# Each agent will see different observations based on message visibility
52
+
observations, rewards, done, truncations, info = env.step(actions)
Converts agent actions to human-readable language.
186
+
Converts agent actions to human-readable language, filtered for a specific viewer. Private messages are only included if the viewer is the sender or a recipient.
169
187
170
188
### `_map_gender_to_adj`
171
189
```python
@@ -206,6 +224,14 @@ Renders text viewable by a specific agent using XMLRenderer.
206
224
207
225
---
208
226
227
+
## Action Space
228
+
229
+
The action space for each agent is a `Dict` space with:
230
+
-`action_type`: A `LiteralSpace` that samples string literals (e.g., `"speak"`, `"none"`, `"action"`) from`available_action_types`
231
+
-`argument`: A `Text` space (max256 characters) for the action content
232
+
233
+
**Note**: The `action_type`is now a string literal, not an integer index. When sampling from the action space, you'll get strings like `"speak"` instead of integers like `0`.
234
+
209
235
## Usage Example
210
236
Here's a typical usage example starting an episode in the environment:
Copy file name to clipboardExpand all lines: docs/pages/python_API/messages/message_classes.md
+31-4Lines changed: 31 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,16 +74,32 @@ Represents the environment's response to the interaction.
74
74
75
75
### `AgentAction`
76
76
77
-
Represents an action taken by an agent.
77
+
Represents an action taken by an agent. Actions can be either public (visible to all agents) or private (visible only to specific recipients).
78
78
79
79
#### Attributes
80
80
81
-
-`action_type: ActionType`: The type of action.
82
-
-`argument: str`: The argument associated with the action.
81
+
-`action_type: ActionType`: The type of action. Can be one of: `"none"`, `"speak"`, `"non-verbal communication"`, `"action"`, or `"leave"`.
82
+
-`argument: str`: The argument associated with the action (e.g., the utterance for `"speak"`, the description for `"action"`).
83
+
-`to: list[str] | None`: (Optional) List of recipient agent names. When specified, the action is a private message visible only to the sender and the listed recipients. When `None` or empty, the action is public and visible to all agents. Defaults to `None`.
83
84
84
85
#### Methods
85
86
86
-
-`to_natural_language(self) -> str`: Returns a string describing the agent's action.
87
+
-`to_natural_language(self) -> str`: Returns a string describing the agent's action. Private messages are prefixed with `[private to {recipients}]`.
88
+
89
+
#### Private Messages
90
+
91
+
Private messages allow agents to communicate privately with specific recipients. When an action has a `to` field specified:
92
+
93
+
- The action is only visible to the sender and the agents listed in `to`
94
+
- Other agents will not see the action in their observations
95
+
- The `to` field is validated to ensure recipients are valid agent names and the sender cannot target themselves
96
+
97
+
#### Validation
98
+
99
+
The `to` field is validated when creating an `AgentAction` with context:
100
+
- Recipients must be valid agent names in the environment
101
+
- Senders cannot send private messages to themselves
102
+
- Invalid recipients will raise a `ValueError` with details about allowed recipients
0 commit comments