Flayer Functions
Flayer functions expose game-specific operations and state to an AI agent through named RPC calls. Use them for actions and observations that are more reliable or precise when the game supplies structured access.
Design functions for agents
Give each function a clear public name and description. Keep it focused on one action or observation, and make parameters explicit so the agent can choose valid values.
Common functions include:
- A state query that returns a JSON snapshot with an interaction flag, the current scene, and useful game-specific values.
- A navigation or camera action that moves toward a target over multiple frames.
- A test control that changes game state, such as granting an item or loading a level.
- Small queries that confirm whether an interaction succeeded.
The exact registration API and supported value types depend on the engine. See the Unity SDK or Unreal Engine SDK guides for implementation details.
Built-in functions
The SDKs provide default functions such as game_state, reset, echo, and pause. Game implementations can provide their own handlers for these names where the engine SDK supports overrides. The fallback game_state returns basic context; the fallback reset reports that no reset action is available.
Handler results and diagnostics
A function returns a supported value when the agent needs a result. Use void when the operation does not produce a useful value, where supported by the engine SDK. For an operation that spans multiple frames, use the engine SDK’s asynchronous handler or promise pattern.
Use the engine’s normal logging facilities for diagnostics. SDK 2 forwards engine logs to game.log while the connection is active. A handler failure is reported to the caller as an EL5 error.
Function discovery includes public names and descriptions. Engine SDKs can also expose argument descriptions, defaults, coordinate hints, and visibility rules.