AppFunctionBehaviorHints


@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.CLASS])
@Retention(value = AnnotationRetention.BINARY)
annotation AppFunctionBehaviorHints


Declares advisory hints about the runtime behavior of an app function.

Apply this annotation to a function annotated with AppFunctionDeclaration or an interface annotated with AppFunctionSignature to populate AppFunctionMetadata.behaviorHints with an AppFunctionBehaviorHintsMetadata. If an app function is not annotated with AppFunctionBehaviorHints, AppFunctionMetadata.behaviorHints is null.

The properties conform to the Model Context Protocol (MCP) ToolAnnotations specification: isReadOnly, isDestructive, isIdempotent, and isOpenWorld.

Behavior hints have the following characteristics:

  • Advisory only (no binding contract): Hints describe how the function behaves without prescribing or enforcing how callers react. Any policy based on hints (such as showing a warning before invoking a destructive function) is determined solely by the caller.

  • No guarantee of accuracy: Neither the library nor the platform verifies that declared hints match the function's implementation. Callers should treat hints from untrusted apps as untrusted and never make security-critical decisions based solely on them.

  • No validation: Hint values and combinations are not validated at declaration time or reading time. Behavior hints are bespoke signals between the providing app (server) and caller (client) that the library does not mediate; the declared values are preserved as-is for the client and server to interpret.

Example usage for service-based functions:

@AppFunctionDeclaration(isDescribedByKDoc = false)
@AppFunctionBehaviorHints(
isReadOnly = false,
isDestructive = true,
isIdempotent = true,
isOpenWorld = false,
)

suspend fun deleteNote(noteId: String) { ... }

Example usage for dynamically registered functions:

@AppFunctionSignature(
scope = AppFunctionMetadata.SCOPE_GLOBAL,
appFunctionXmlFileName = "dynamic_signature_definitions",
isDescribedByKDoc = false,
)

@AppFunctionBehaviorHints(
isReadOnly = true,
isDestructive = false,
isIdempotent = true,
isOpenWorld = false,
)

fun interface SearchNotesSignature {
suspend fun searchNotes(query: String): List<Note>
}

Summary

Public constructors

AppFunctionBehaviorHints(
    isReadOnly: Boolean,
    isDestructive: Boolean,
    isIdempotent: Boolean,
    isOpenWorld: Boolean
)

Public properties

Boolean

Whether the app function may perform destructive updates to its environment, as opposed to purely additive updates.

Boolean

Whether calling the app function repeatedly with the same arguments has no additional effect on its environment.

Boolean

Whether the app function may interact with an external "open world" of entities, as opposed to operating strictly within a closed domain.

Boolean

Whether the app function does not modify its environment.

Public constructors

AppFunctionBehaviorHints

Added in 1.1.0-alpha01
AppFunctionBehaviorHints(
    isReadOnly: Boolean,
    isDestructive: Boolean,
    isIdempotent: Boolean,
    isOpenWorld: Boolean
)

Public properties

isDestructive

Added in 1.1.0-alpha01
val isDestructive: Boolean

Whether the app function may perform destructive updates to its environment, as opposed to purely additive updates.

Destructive updates include deleting or overwriting existing data, whereas additive updates only create new records. Meaningful only when the function modifies its environment (that is, when isReadOnly is false).

isIdempotent

Added in 1.1.0-alpha01
val isIdempotent: Boolean

Whether calling the app function repeatedly with the same arguments has no additional effect on its environment.

Meaningful only when the function modifies its environment (that is, when isReadOnly is false).

isOpenWorld

Added in 1.1.0-alpha01
val isOpenWorld: Boolean

Whether the app function may interact with an external "open world" of entities, as opposed to operating strictly within a closed domain.

Examples include searching the web, sending messages to external recipients, or calling third-party services, as opposed to operating strictly within local app storage.

isReadOnly

Added in 1.1.0-alpha01
val isReadOnly: Boolean

Whether the app function does not modify its environment.