Skip to content

Agent Shared State

Give your AI agents shared state. Copy, paste, run.

If you want the installation guide for Claude, Codex, ChatGPT, Cursor, and Continue, see INSTALL.md.

  1. Define — Register save_state and read_state as tools your LLM can call.
  2. Handle — When the LLM calls a tool, your handler sends the request to the echoValue API.
  3. Share — Any agent with the same token can read and write. Shared state, zero config.
# pip install anthropic requests
import requests
from anthropic import Anthropic
# Get a free token: curl https://api.echovalue.dev/token -d 'token=new'
TOKEN = "your-echovalue-token"
BASE = "https://api.echovalue.dev/kv"
# 1. Define the tools
tools = [
{
"name": "save_state",
"description": "Save a key-value pair to shared agent state",
"input_schema": {
"type": "object",
"properties": {
"group": {"type": "string", "description": "Namespace / bucket"},
"key": {"type": "string", "description": "Identifier"},
"value": {"type": "string", "description": "Data to store"},
"ttl": {"type": "integer", "description": "Expiry in seconds"}
},
"required": ["group", "key", "value"]
}
},
{
"name": "read_state",
"description": "Read a value from shared agent state",
"input_schema": {
"type": "object",
"properties": {
"group": {"type": "string", "description": "Namespace / bucket"},
"key": {"type": "string", "description": "Identifier"}
},
"required": ["group", "key"]
}
}
]
# 2. Handle tool calls → echoValue API
def run_tool(name, args):
headers = {"x-token": TOKEN}
if name == "save_state":
ttl = args.get("ttl", 86400)
r = requests.post(
f"{BASE}/{args['group']}/{args['key']}?ttl={ttl}",
data=args["value"], headers=headers)
return r.text
if name == "read_state":
r = requests.get(
f"{BASE}/{args['group']}/{args['key']}",
headers=headers)
return r.text
# 3. Run the agent
client = Anthropic()
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
tools=tools,
messages=[{"role": "user", "content": "Save status=done for the import pipeline"}]
)
# 4. Process tool calls from the response
for block in response.content:
if block.type == "tool_use":
result = run_tool(block.name, block.input)
print(f"{block.name}{result}")
# save_state → OK