Skip to main content

Agent Decorators

The Agent Decorators module provides a configuration-as-code system for SAP AI agents. Annotate Python functions with decorators to expose configuration fields — prompts, model selections, and settings — to a low-code UI.

Quick Start

from sap_cloud_sdk.agent_decorators import prompt_section, agent_model


# Define a prompt with a coded default
@prompt_section(
key="prompts.system",
label="System Prompt",
description="Main system prompt for the agent",
)
def system_prompt() -> str:
return "You are a helpful assistant."


# Define the model selection
@agent_model(key="config.model", label="LLM Model")
def model_name() -> str:
return "gpt-4"

Decorators

@prompt_section

Expose a prompt section for editing.

from sap_cloud_sdk.agent_decorators import prompt_section


@prompt_section(
key="prompts.identity",
label="Agent Identity",
description="Core identity and role definition",
validation={"format": "text", "max_length": 500},
)
def identity_prompt() -> str:
return "You are an expert assistant specializing in SAP systems."

For the complete API reference and more examples, see the Agent Decorators user guide in the cloud-sdk-python repository.