Skip to content

Commit

Permalink
feat(docs): add local agent inspector guide into docs (#1002)
Browse files Browse the repository at this point in the history
Co-authored-by: James Riehl <[email protected]>
  • Loading branch information
FelixNicolaeBucsa and jrriehl authored Oct 21, 2024
1 parent 81b3dae commit 215861d
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pages/guides/agents/intermediate/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"tags": ["Intermediate", "Python", "Communication", "Mailbox"],
"timestamp": true
},
"local-agent-inspector": {
"title": "Local Agent Inspector",
"tags": ["Intermediate", "Python", "Agents"],
"timestamp": true
},
"agent-functions": {
"title": "Agent Functions",
"tags": ["Intermediate", "Python", "Functions", "AI Engine"],
Expand Down
87 changes: 87 additions & 0 deletions pages/guides/agents/intermediate/local-agent-inspector.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Callout } from 'nextra/components'

# Local Agent Inspector

The Local Agent Inspector is a developer tool on Agentverse that enhances the debugging and monitoring experience for [Agents running on a local infrastructure](https://fetch.ai/docs/guides/agents/intermediate/agent-types#local-agents). It allows you to track and understand the real-time behavior of these Agents, whether they are connected to Agentverse or not. The tool offers developers detailed insights into your local agent’s performance and interactions, even though the agent itself is run within your infrastructure.

<Callout type="info" emoji="ℹ️">
Local Agents can communicate and interact with other Agents and Functions connected to the Agentverse and Fetch Network through a Mailbox. For more information on Mailbox and how to connect local Agents and their function to the Agentverse, have a look at these guides:

- [Agent Mailbox](https://fetch.ai/docs/guides/agents/intermediate/mailbox).
- [Options for running local Agents]()
- [Agent Functions ](https://fetch.ai/docs/guides/agents/intermediate/agent-functions).
- [Agentverse Functions: register your Agents Functions on the Agentverse!](https://fetch.ai/docs/guides/agentverse/agentverse-functions/registering-agent-services).
</Callout>

The Inspector tool provides developers with multiple key insights, including the agent’s address, details about its local and external endpoints, the types of messages sent and received, and comprehensive data about the sender and recipient of each message. This functionality makes it easier to monitor communication flows, troubleshoot issues, and analyze performance in real-time.

By visualizing this information, the Local Agent Inspector allows you to maintain real-time oversight of how your Agent interacts with other Agents and systems, facilitating easier troubleshooting, performance analysis, and optimizing communication flows. This functionality is particularly valuable for complex applications where local agents are responsible for processing real-time tasks, interacting with other agents, or managing resources directly. It provides a way to see how your agent is performing within a networked environment, while still retaining the benefits of local execution and control.

All messages data regarding a particular local agent are then presented as a list through which it is also possible to access the payload for the message being examined.

while agents running in a bureau are not supported in the initial version, we will be adding support for this very soon

If you're managing multiple local agents, the Inspector will show a complete list of all running agents. While support for agents managed through a `Bureau` is not available in the initial version, it will be added soon. This way, yo will have a complete view of your Agents running locally alongside with the relevant details.

In the near future, developers will also have the option to connect their local agents directly to Agentverse through the Inspector, making it even easier to manage and monitor agent interactions.

## How to access the Local Agent Inspector

You can access the Local Agent Inspector by first coding and defining your Agent.

For instance, consider the following simple local agent:

```py copy filename="agent_inspector_example.py"
from uagents import Agent, Context, Model
from uagents.setup import fund_agent_if_low

class Message(Model):
message: str


bob = Agent(
name="Bob",
port=8001,
seed="BobSecretPhrase",
endpoint=["http://127.0.0.1/:8001/submit"],
)

fund_agent_if_low(bob.wallet.address())

print(f"Your agent's address is: {bob.address}")

@bob.on_message(model=Message)
async def message_handler(ctx: Context, sender: str, msg: Message):
ctx.logger.info(f'Received message from {sender}: {msg.message}')

await ctx.send(sender, Message(message="Hello There!"))


if __name__ == "__main__":
bob.run()
```

Once you successfully run your local agent and register it into the Almanac, you will be able to access the Inspector via the terminal log, which provides a dedicated link to the Inspector page.

By running the above Agent, the output you get should be similar to the following:

```
Your agent's address is: agent1qvrapvpxltu54tt3qnud5mlkul9y9d9tfn7xfpq4ec74cq4mkym6yl3jkdw
INFO: [ Bob]: Registration on Almanac API successful
INFO: [ Bob]: Registering on Almanac API successful
INFO: [ Bob]: Registering on almanac contract...
INFO: [ Bob]: Registering on almanac contract...complete
INFO: [ Bob]: Agent inspector available at https://agentverse.ai/inspect/?uri=http://127.0.0.1:8001
INFO: [ Bob]: Starting server on http://0.0.0.0:8001 (Press CTRL+C to quit)
```


By clicking on the dedicated link depicted here, you will then be redirected to the **Inspector Dashboard**.

![](src/images/guides/inspector/inspector_1.png)

As you can see, here your local Agent will be listed and a pop-up message will appear saying that your Agent was added to the list. By clicking the dedicated **Connect Agent** button, you are able to connect Agents to the inspector by providing the Agent Address.

Instead, by clicking on the Agent box, you can enter the Inspector Dashboard and check out all details about your Local Agent and its messages:

![](src/images/guides/inspector/inspector_2.png)
Binary file added src/images/guides/inspector/inspector_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/guides/inspector/inspector_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 215861d

Please sign in to comment.