Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AGenUI AGenUI FunctionCallConfig

From Leeroopedia
Knowledge Sources
Domains Software_Architecture, UI_Framework
Last Updated 2026-10-24 17:21 GMT

Overview

Configuration data class for function calls, storing namespace, name, description, and return type metadata, provided by the AGenUI C++ core.

Description

The `FunctionCallConfig` class holds the metadata that describes a function call: its `namespace`, `name`, `description`, and `returnType`. It is used by `FunctionCallManager` to register and catalog function calls, and by `IFunctionCall::getConfig()` to self-describe built-in functions.

The class provides JSON serialization via `fromJson()` / `toJson()` and a `getFullName()` helper that returns `namespace::name` (or just `name` if no namespace). Validation (`isValid()`) requires only that `name` is non-empty.

Usage

  • Host registration: construct from JSON config when registering a platform function via `engine->registerFunction(configJson, &myFunction)`.
  • Builtin self-description: each `IFunctionCall` subclass returns a `FunctionCallConfig` from its `getConfig()` override.
  • Catalog export: `FunctionCallManager::exportCatalog()` serializes all configs to JSON.

Code Reference

Source Location

Signature

// core/src/function_call/agenui_functioncall_config.h
namespace agenui {

class FunctionCallConfig {
public:
    FunctionCallConfig();
    ~FunctionCallConfig();

    /// Create a FunctionCallConfig from a JSON object
    static FunctionCallConfig fromJson(const nlohmann::json& json);

    /// Serialize to a JSON object
    nlohmann::json toJson() const;

    /// Check whether the configuration is valid (name must be non-empty)
    bool isValid() const;

    /// Get the fully qualified functionCall name (namespace::name)
    std::string getFullName() const;

    // Getters
    const std::string& getNamespace() const;
    const std::string& getName() const;
    const std::string& getDescription() const;
    const std::string& getReturnType() const;

    // Setters
    void setNamespace(const std::string& ns);
    void setName(const std::string& name);
    void setDescription(const std::string& desc);
    void setReturnType(const std::string& type);

private:
    std::string _namespace;
    std::string _name;
    std::string _description;
    std::string _returnType;
};

} // namespace agenui

Import

#include "function_call/agenui_functioncall_config.h"

I/O Contract

Inputs

Name Type Required Description
json (fromJson) `const nlohmann::json&` Yes JSON object with "namespace", "name", "description", "returnType" string fields
ns `const std::string&` No Namespace for the function call (e.g. "agenui.platform")
name `const std::string&` Yes Short function name (e.g. "toast")
desc `const std::string&` No Human-readable description
type `const std::string&` No Return type string (e.g. "object", "string")

Outputs

Name Type Description
fromJson returns `FunctionCallConfig` Parsed config instance
toJson returns `nlohmann::json` JSON object with namespace, name, description, returnType
getFullName returns `std::string` "namespace::name" or just "name" if no namespace
isValid returns `bool` True if name is non-empty

Usage Examples

Creating a Config from JSON

#include "function_call/agenui_functioncall_config.h"

nlohmann::json configJson = R"({
    "namespace": "agenui.platform",
    "name": "toast",
    "description": "Show a Toast message",
    "returnType": "object"
})"_json;

auto config = agenui::FunctionCallConfig::fromJson(configJson);

// Validate
if (!config.isValid()) {
    printf("Invalid config: name is empty\n");
    return;
}

printf("Full name: %s\n", config.getFullName().c_str());
// Output: agenui.platform::toast

Building a Config Programmatically

agenui::FunctionCallConfig config;
config.setNamespace("agenui.format");
config.setName("formatDate");
config.setDescription("Formats a timestamp into a string using a pattern.");
config.setReturnType("string");

// Serialize to JSON for catalog export
nlohmann::json json = config.toJson();
printf("Catalog entry: %s\n", json.dump(2).c_str());

Related Pages

Implements Principle

Requires Environment

Related Implementations

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment