Skip to content

Commit 4876a26

Browse files
committed
Improve the CLI to handle the discovery agent specially
1 parent 1eca7e3 commit 4876a26

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

coagent/cli/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ async def run(
5050
else:
5151
agent_type, session_id = parts[0], uuid.uuid4().hex
5252

53+
probe = True
54+
if agent_type == "discovery":
55+
# The discovery agent is a system-provided agent, which is a distributed
56+
# singleton and is always available.
57+
session_id = ""
58+
probe = False
59+
5360
if server.startswith("nats://"):
5461
runtime = NATSRuntime.from_servers(server)
5562
elif server.startswith(("http://", "https://")):
@@ -62,7 +69,11 @@ async def run(
6269
try:
6370
if not stream:
6471
response = await runtime.channel.publish(
65-
addr, msg, request=True, timeout=10
72+
addr,
73+
msg,
74+
request=True,
75+
timeout=10,
76+
probe=probe,
6677
)
6778
print_msg(response, oneline, filter)
6879
else:

examples/discovery/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ python examples/discovery/server.py team2.dev "Dev Engineer in Team 2."
2727
python examples/discovery/server.py team3.qa "QA Engineer in Team 3."
2828
```
2929

30-
Then start a client in another terminal.
30+
Then discover the available agent types using the `coagent` CLI:
3131

3232
```bash
33-
python examples/discovery/client.py team1
33+
coagent discovery -H type:DiscoveryQuery -F .content.agents -d '{"namespace":"team1"}'
34+
```
35+
36+
Or start a more-friendly client in another terminal:
37+
38+
```bash
39+
python examples/discovery/client.py --namespace team1
3440
```

0 commit comments

Comments
 (0)