类 MessageMetadataKeys

java.lang.Object
io.agentscope.core.message.MessageMetadataKeys

public final class MessageMetadataKeys extends Object
Constants for well-known message metadata keys.

This class defines standard metadata keys used across the framework to ensure consistency and avoid magic strings.

  • 字段详细资料

    • BYPASS_MULTIAGENT_HISTORY_MERGE

      public static final String BYPASS_MULTIAGENT_HISTORY_MERGE
      Metadata key to bypass history merging in multiagent formatters.

      Messages with this flag set to true will be kept as separate messages rather than being merged into conversation history when using multiagent formatters.

      Type: Boolean

      Example:

      
       Map<String, Object> metadata = new HashMap<>();
       metadata.put(MessageMetadataKeys.BYPASS_MULTIAGENT_HISTORY_MERGE, true);
       Msg msg = Msg.builder()
           .role(MsgRole.USER)
           .content(TextBlock.builder().text("Important reminder").build())
           .metadata(metadata)
           .build();
       
      另请参阅:
    • STRUCTURED_OUTPUT_REMINDER

      public static final String STRUCTURED_OUTPUT_REMINDER
      Metadata key to mark structured output reminder messages.

      This flag is used internally by ReActAgent to identify temporary reminder messages that guide the model to use the generate_response tool for structured output.

      Type: Boolean

      Internal use only

      另请参阅:
    • STRUCTURED_OUTPUT_REMINDER_TYPE

      public static final String STRUCTURED_OUTPUT_REMINDER_TYPE
      Metadata key for the type of structured output reminder.

      Stores the StructuredOutputReminder mode (e.g., TOOL_CHOICE, PROMPT) used when creating reminder messages. This allows the hook to apply mode-specific behavior.

      Type: String (StructuredOutputReminder enum name)

      Internal use only

      另请参阅:
    • CHAT_USAGE

      public static final String CHAT_USAGE
      Metadata key for chat usage statistics.

      Contains token usage information (input tokens, output tokens, and time) accumulated during model generation. This allows users to track token consumption for cost estimation and usage monitoring.

      Type: ChatUsage

      Example:

      
       Msg msg = agent.call(userMsg).block();
       ChatUsage usage = msg.getChatUsage();
       if (usage != null) {
           System.out.println("Input tokens: " + usage.getInputTokens());
           System.out.println("Output tokens: " + usage.getOutputTokens());
           System.out.println("Total tokens: " + usage.getTotalTokens());
       }
       
      另请参阅:
    • STRUCTURED_OUTPUT

      public static final String STRUCTURED_OUTPUT
      Metadata key for structured output data.

      Contains the structured response data generated by the generate_response tool. This key is used to isolate structured output from other metadata to avoid conflicts.

      Type: Map<String, Object> or user-defined POJO

      Example:

      
       Msg msg = agent.call(userMsg, WeatherResponse.class).block();
       WeatherResponse response = msg.getStructuredData(WeatherResponse.class);
       
      另请参阅:
    • CACHE_CONTROL

      public static final String CACHE_CONTROL
      Metadata key to mark a message for prompt caching.

      When set to true, the formatter will add cache_control: {"type": "ephemeral"} to this message during formatting. This allows users to manually mark specific messages for caching, independent of the automatic cache control strategy configured via GenerateOptions.getCacheControl().

      Manually marked messages take priority over the automatic strategy — they will not be overwritten.

      Type: Boolean

      Example:

      
       Map<String, Object> metadata = new HashMap<>();
       metadata.put(MessageMetadataKeys.CACHE_CONTROL, true);
       Msg msg = Msg.builder()
           .role(MsgRole.USER)
           .textContent("Important context to cache...")
           .metadata(metadata)
           .build();
       
      另请参阅: