Skip to content

feat(ai): add rmq.message.trace tool to the AI tool catalog - #1127

Closed
123123213weqw wants to merge 1 commit into
apache:rocketmq-studiofrom
123123213weqw:fix/ai-tool-message-trace
Closed

feat(ai): add rmq.message.trace tool to the AI tool catalog#1127
123123213weqw wants to merge 1 commit into
apache:rocketmq-studiofrom
123123213weqw:fix/ai-tool-message-trace

Conversation

@123123213weqw

Copy link
Copy Markdown

Extends the Studio AI tool catalog (shared by Web/AI/MCP/CLI — track 3 "AI Native") with a message trace tool.

  • New ToolHandler rmq.message.trace backed by the standard MessageProvider.getMessageTrace, surfacing the produce/consume/transaction timeline for a message id.
  • Tool definition registered in the YAML contract (rmq-tools.yaml) with input/output JSON Schema; requires cluster + msgId per the catalog convention.
  • Read-only, L1 risk level, no side effects.
  • Unit tests for the handler, plus updated catalog/gateway tests.

Related: #1024 (track 3 AI Native), #998 (MCP server and CLI).

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The rmq.message.trace tool implementation looks clean and follows the existing tool handler patterns well. However, CI is failing due to a compilation error that needs to be fixed before this can be merged.

Findings

  • [Critical] MessageTraceToolHandler.java:48messageProvider.getMessageTrace(msgId) is called with 1 argument, but MessageProvider.getMessageTrace now requires 2 arguments (String instanceId, String msgId). The MessageProvider interface was updated (likely by the instance-scoping PRs #1128/#1130) to require an instanceId parameter.

Fix

The execute() method needs to extract instanceId from the input map and pass it through:

@Override
public Object execute(Map<String, Object> input) {
    String instanceId = (String) input.get("cluster"); // or a dedicated instanceId field
    String msgId = (String) input.get("msgId");
    TraceRecordVO trace = messageProvider.getMessageTrace(instanceId, msgId);
    return project(msgId, trace);
}

You may also need to update the tool's inputSchema in rmq-tools.yaml if the cluster field maps to instanceId.

Suggestions

  • Consider adding a null check for msgId — if it's missing from the input, the current code would pass null to the provider, which could cause an NPE deeper in the stack.
  • The project() method could benefit from handling a null trace gracefully (e.g., if the message ID is not found).

Automated review by github-manager-bot

@lizhimins

Copy link
Copy Markdown
Member

Closing: this area belongs to Track 3 (AI Native), which already has a complete design in progress (see #1024). Further LLM/AI tool catalog changes should follow that design discussion instead of ad-hoc PRs. Thanks for the effort! / 关闭说明:该改动属于赛道三(AI Native)范围,赛道三已有完整的设计方案正在推进(见 #1024),AI 工具目录相关改动请跟随该设计讨论,不再单独接收零散 PR。感谢贡献!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants