Skip to content

Agent Config Store

The Agent Config Store provides a modular configuration management system for agent-based applications. It allows developers to register configurable modules, query/update parameters, and execute module-specific commands through a simple REST API.

This is ideal for agents that need dynamic configurability during runtime.


Introduction

Modern AI agents and services often require fine-grained, runtime-tunable configuration — for example, thresholds, operational modes, toggles, or restart/reset hooks.

This module helps expose and manage these configurations via:

  • Module registration
  • Key-value based config management
  • Command execution (e.g., reset, print, toggle)
  • RESTful API on port 7777

Importing

from agent_sdk.config_store import AgentConfigManager, start_server

Config Store Functions

Class: AgentConfigManager

This class manages all registered modules and provides helper methods to interact with them.

Initialization
manager = AgentConfigManager()
Methods
Method Description
register(module_name, module_object) Register a module with the config manager
unregister(module_name) Unregister a module
get(module_name, key) Retrieve a key’s value from the module
set(module_name, key, value) Set a key’s value inside the module
list() List all modules and their available config/commands
list_commands(module_name) List commands supported by the module
execute_config_command(module_name, command, command_data) Execute a config command with input

Registering Modules

To register a module, it must implement the following methods:

- get(key: str) -> Any
- set(key: str, value: Any) -> None
- list() -> List[str]
- list_commands() -> List[str]
- execute_config_command(command: str, command_data: dict) -> Any

Example

class ExampleModule:
    def __init__(self):
        self.params = {"mode": "auto", "threshold": 0.75}

    def get(self, key):
        return self.params[key]

    def set(self, key, value):
        self.params[key] = value

    def list(self):
        return list(self.params.keys())

    def list_commands(self):
        return ["reset", "print_config"]

    def execute_config_command(self, command, command_data):
        if command == "reset":
            self.params = {"mode": "auto", "threshold": 0.75}
            return {"status": "reset"}
        elif command == "print_config":
            return {"config": self.params}
        raise ValueError("Invalid command")
manager = AgentConfigManager()
manager.register("example", ExampleModule())

Starting the Config Server

from agent_sdk.config_store import start_server

start_server(port=7777)

This launches a Flask app on a background thread, making the REST APIs available at http://localhost:7777.


API Endpoints and Usage

Each API returns a JSON response with success: true/false and optionally data or message.

POST /execute

Executes a configuration command on the specified module.

Request body:

{
  "module_name": "example",
  "command": "reset",
  "command_data": {}
}

Curl example:

curl -X POST http://localhost:7777/execute \
  -H "Content-Type: application/json" \
  -d '{"module_name": "example", "command": "reset", "command_data": {}}'

GET /get/<module_name>/<key>

Retrieves a config key’s value.

Curl example:

curl http://localhost:7777/get/example/mode

POST /set/<module_name>/<key>/<value>

Sets a config key to a new value.

Curl example:

curl -X POST http://localhost:7777/set/example/mode/manual

GET /list

Lists all registered modules along with their parameters and commands.

Curl example:

curl http://localhost:7777/list

GET /list_commands/<module_name>

Lists all supported commands for a given module.

Curl example:

curl http://localhost:7777/list_commands/example

Usage Example

from agent_sdk.config_store import AgentConfigManager, start_server

class ThresholdModule:
    def __init__(self):
        self.config = {"threshold": 0.5, "enabled": True}

    def get(self, key):
        return self.config[key]

    def set(self, key, value):
        self.config[key] = value

    def list(self):
        return list(self.config.keys())

    def list_commands(self):
        return ["toggle", "status"]

    def execute_config_command(self, command, command_data):
        if command == "toggle":
            self.config["enabled"] = not self.config["enabled"]
            return {"enabled": self.config["enabled"]}
        elif command == "status":
            return self.config
        else:
            raise ValueError("Invalid command")

manager = AgentConfigManager()
manager.register("threshold", ThresholdModule())
start_server(port=7777)

Once the server starts, you can now interact with this module using REST APIs.