@@ -21,25 +21,27 @@ The simplest way to use the Echo environment is through the `EchoEnv` class. The
2121
2222``` python
2323import asyncio
24- from echo_env import EchoAction , EchoEnv
24+ from echo_env import CallToolAction , EchoEnv
2525
2626async def main ():
2727 # Create environment from Docker image
2828 client = await EchoEnv.from_docker_image(" echo-env:latest" )
2929
3030 async with client:
31- # Reset
32- result = await client.reset()
33- print (f " Reset: { result.observation.echoed_message} " )
31+ await client.reset()
3432
3533 # Send multiple messages
3634 messages = [" Hello, World!" , " Testing echo" , " Final message" ]
3735
3836 for msg in messages:
39- result = await client.step(EchoAction(message = msg))
37+ result = await client.step(
38+ CallToolAction(
39+ tool_name = " echo_message" ,
40+ arguments = {" message" : msg},
41+ )
42+ )
4043 print (f " Sent: ' { msg} ' " )
41- print (f " → Echoed: ' { result.observation.echoed_message} ' " )
42- print (f " → Length: { result.observation.message_length} " )
44+ print (f " → Echoed: ' { result.observation.result} ' " )
4345 print (f " → Reward: { result.reward} " )
4446
4547asyncio.run(main())
@@ -48,12 +50,17 @@ asyncio.run(main())
4850For ** synchronous usage** , use the ` .sync() ` wrapper:
4951
5052``` python
51- from echo_env import EchoAction , EchoEnv
53+ from echo_env import CallToolAction , EchoEnv
5254
5355with EchoEnv(base_url = " http://localhost:8000" ).sync() as client:
54- result = client.reset()
55- result = client.step(EchoAction(message = " Hello!" ))
56- print (result.observation.echoed_message)
56+ client.reset()
57+ result = client.step(
58+ CallToolAction(
59+ tool_name = " echo_message" ,
60+ arguments = {" message" : " Hello!" },
61+ )
62+ )
63+ print (result.observation.result)
5764```
5865
5966The ` EchoEnv.from_docker_image() ` method handles:
@@ -73,23 +80,20 @@ docker build -t echo-env:latest -f envs/echo_env/server/Dockerfile .
7380
7481## Environment Details
7582
76- ### Action
77- ** EchoAction ** : Contains a single field
78- - ` message ` (str) - The message to echo back
83+ ### Tools
84+ - ` echo_message(message) ` - Echo the provided message
85+ - ` echo_with_length( message) ` - Echo the message and include its length
7986
8087### Observation
81- ** EchoObservation** : Contains the echo response and metadata
82- - ` echoed_message ` (str) - The message echoed back
83- - ` message_length ` (int) - Length of the message
84- - ` reward ` (float) - Reward based on message length (length × 0.1)
85- - ` done ` (bool) - Always False for echo environment
88+ ** CallToolObservation** : Contains the tool result and metadata
89+ - ` result ` - The tool return value
90+ - ` reward ` (float) - Reward returned by the environment
91+ - ` done ` (bool) - Always ` False ` for the echo environment
8692- ` metadata ` (dict) - Additional info like step count
8793
8894### Reward
89- The reward is calculated as: ` message_length × 0.1 `
90- - "Hi" → reward: 0.2
91- - "Hello, World!" → reward: 1.3
92- - Empty message → reward: 0.0
95+ The echo environment returns ` 0.0 ` reward for tool calls. It is intended as a
96+ minimal MCP integration example rather than a reward-shaping reference.
9397
9498## Advanced Usage
9599
@@ -98,17 +102,27 @@ The reward is calculated as: `message_length × 0.1`
98102If you already have an Echo environment server running, you can connect directly:
99103
100104``` python
101- from echo_env import EchoAction , EchoEnv
105+ from echo_env import CallToolAction , EchoEnv
102106
103107# Async usage
104108async with EchoEnv(base_url = " http://localhost:8000" ) as client:
105- result = await client.reset()
106- result = await client.step(EchoAction(message = " Hello!" ))
109+ await client.reset()
110+ result = await client.step(
111+ CallToolAction(
112+ tool_name = " echo_message" ,
113+ arguments = {" message" : " Hello!" },
114+ )
115+ )
107116
108117# Sync usage
109118with EchoEnv(base_url = " http://localhost:8000" ).sync() as client:
110- result = client.reset()
111- result = client.step(EchoAction(message = " Hello!" ))
119+ client.reset()
120+ result = client.step(
121+ CallToolAction(
122+ tool_name = " echo_message" ,
123+ arguments = {" message" : " Hello!" },
124+ )
125+ )
112126```
113127
114128Note: When connecting to an existing server, closing the client will NOT stop the server.
0 commit comments