Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): add local agent inspector guide into docs #1002

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
85 changes: 85 additions & 0 deletions pages/guides/agents/intermediate/local-agent-inspector.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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 in the Agentverse environment, 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.
FelixNicolaeBucsa marked this conversation as resolved.
Show resolved Hide resolved

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.

If you are managing multiple local agents, for example, through a `Bureau`, the Inspector will display a complete list of all agents running locally, along with the relevant details mentioned earlier.
FelixNicolaeBucsa marked this conversation as resolved.
Show resolved Hide resolved

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.
Loading