Skip to content

[Feature Request] Allow passing optional metadata to the LLM backend #100

@pamodham

Description

@pamodham

Currently, the agent definition in the Agent Kernel (AK) framework does not appear to have a dedicated mechanism for passing additional, arbitrary parameters or metadata to the underlying LLM backend.

This becomes a limitation when an LLM backend (like OpenAI, Anthropic, Ollama, or a custom provider) supports specific, non-standard options that aren't part of the core agent configuration.

Use Cases:

  • Passing a chat_session_id field for an OpenAI-compatible API backend.
  • Specifying provider-specific parameters like thinking_enabled.
  • Sending custom metadata that a specific LLM endpoint is configured to receive.

Proposed Solution

A clean and effective solution would be to leverage the optional metadata field that is already part of the standard OpenAI-compatible completions API.

Reference: OpenAI API Documentation

This field would be designed to accept an arbitrary key-value object (e.g., a JSON object or dictionary) provided by the user.
When Agent Kernel prepares the API request for the LLM backend, it could then pass them directly as the value for the top-level metadata parameter in the outgoing JSON payload.

This approach would provide a flexible and clean "pass-through" mechanism. It would allow users to send any additional details (like session_id or context) that their specific LLM endpoint is configured to read from the metadata object. A key benefit is that this could be implemented without requiring the core framework to explicitly support every possible custom parameter.

Example

As the below example, Agent Kernel could then inject any additional informational accept by the agent and send it in the metadata field in the JSON payload to the completions endpoint:

{
    "method": "post",
    "url": "/chat/completions",
    "headers": {
        "User-Agent": "Agents/Python 0.2.7"
    },
    "json_data": {
        "messages": [
            {
                "role": "user",
                "content": "test"
            },
            {
                "role": "assistant",
                "content": "I'm sorry, I can't answer that particular question. Is there something else I can help you with?"
            },
            {
                "role": "user",
                "content": "test"
            }
        ],
        "model": "gemini-2.0-flash",
        "metadata": {
            "chat_id": "633d3db773347a3a651bc40f",
            "context": {
                "nic": "1236546555V",
                "name": "John Doe",
                "account_type": "savings",
                "account_balance": 5000
            }
        },
        "stream": false
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestl6Feature requests from L6

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions