类 MessageMetadataKeys
This class defines standard metadata keys used across the framework to ensure consistency and avoid magic strings.
-
字段概要
字段修饰符和类型字段说明static final StringMetadata key to bypass history merging in multiagent formatters.static final StringMetadata key to mark a message for prompt caching.static final StringMetadata key for chat usage statistics.static final StringMetadata key for structured output data.static final StringMetadata key to mark structured output reminder messages.static final StringMetadata key for the type of structured output reminder. -
方法概要
-
字段详细资料
-
BYPASS_MULTIAGENT_HISTORY_MERGE
Metadata key to bypass history merging in multiagent formatters.Messages with this flag set to
truewill 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
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
Metadata key for the type of structured output reminder.Stores the
StructuredOutputRemindermode (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
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:
ChatUsageExample:
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
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 POJOExample:
Msg msg = agent.call(userMsg, WeatherResponse.class).block(); WeatherResponse response = msg.getStructuredData(WeatherResponse.class);- 另请参阅:
-
CACHE_CONTROL
Metadata key to mark a message for prompt caching.When set to
true, the formatter will addcache_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 viaGenerateOptions.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();- 另请参阅:
-