fetchai / uAgents

A fast and lightweight framework for creating decentralized agents with ease.
Apache License 2.0
824 stars 223 forks source link

Extend logging capabilities and agent configurability #496

Open Archento opened 1 month ago

Archento commented 1 month ago

We need to improve logging throughout the whole framework and enable the user to configure verbosity as well as output of the logs.

Potential solution could be a config mapping which may be created by the user or generated and filled with default values on demand by running the agent with a CLI argument.

Agent instantiation

agent = Agent(
    name="<your_name>",
    seed="<your_seed>",
    [...],
    config=AgentConfig(
        path="./my_agent.yaml",
        **kwargs   # maybe individual config values
    )
)

my_agent.yaml

name: "bert"
port: 8000
seed: "..."
endpoint: "http://localhost:8000/submit"
enable_wallet_messaging: false
version: "v20.0.9"
log_level: "DEBUG"
log_file: "./${timestamp}_${agent_address}.log"
...

By using this approach it should also be easier to scale agent deployment if we can put every agent init argument inside the config map, enabling the developer to invoke:

configs= ["./config_a.yaml", "./config_b.yaml", ...]  # list of config files

agents = []
for conf in configs:
    agents.append(Agent(config=conf))
Archento commented 2 weeks ago

Add automatic logging of agent address on agent startup.

Archento commented 1 day ago

I think there are two main approaches when it comes to configuration files:

Both can coexist but we may want to force one of the usage of one over the other.

Screenshot 2024-09-12 at 12 17 20


We can think about adding the AgentConfig object to the agent by default so that config handling will be more natively embedded in the framework.

Screenshot 2024-09-12 at 12 28 22


Using yaml files makes handling of multiple agents very easy as the configs just need to be separated by --- for it to be loaded like this:

"""yaml contents
name: alice
seed: ...
---
name: bob
seed: ...
"""

confs = load_configs(PATH) # multiple configs in one file

bureau = Bureau()
for conf in confs:
    bureau.add(Agent(**conf))

bureau.run()

Requirements