Skip to content

Merge duplicate list_objects/list_metadata_objects and describe_object/describe_metadata_object tools - #1091

Merged
hotlong merged 3 commits into
mainfrom
copilot/merge-list-objects-and-metadata-objects
Apr 8, 2026
Merged

Merge duplicate list_objects/list_metadata_objects and describe_object/describe_metadata_object tools#1091
hotlong merged 3 commits into
mainfrom
copilot/merge-list-objects-and-metadata-objects

Conversation

CopilotAI commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

list_objects and list_metadata_objects share the same data source (metadataService.listObjects()), with list_objects being a strictly weaker subset (no filter/includeFields). Same duplication exists for describe_object/describe_metadata_object. This created naming confusion, duplicate ObjectDef/FieldDef types, and gave data_chat agent inferior capabilities.

Changes

  • Unified tool definitions: Created list-objects.tool.ts and describe-object.tool.ts with the richer parameter sets (filter, includeFields, snake_case validation, enableFeatures). Deleted list-metadata-objects.tool.ts and describe-metadata-object.tool.ts.

  • data-tools.ts: Removed LIST_OBJECTS_TOOL, DESCRIBE_OBJECT_TOOL, their handlers, and duplicate ObjectDef/FieldDef types. DATA_TOOL_DEFINITIONS: 5 → 3 tools (query_records, get_record, aggregate_data). DataToolContext no longer requires metadataService.

  • metadata-tools.ts: METADATA_TOOL_DEFINITIONS retains 6 tools, now registering list_objects and describe_object (unified names) with the full-capability handlers.

  • Agents: metadata_assistant references updated from list_metadata_objects/describe_metadata_objectlist_objects/describe_object. data_chat already used these names — no change needed.

  • Exports: Updated tools/index.ts and src/index.tslistObjectsTool/describeObjectTool replace listMetadataObjectsTool/describeMetadataObjectTool.

Registration flow

Both agents get list_objects/describe_object from registerMetadataTools(), which only requires metadataService (always available when data tools are registered):

plugin.start()
├─ registerDataTools(registry, { dataEngine }) → 3 tools
└─ registerMetadataTools(registry, { metadataService }) → 6 tools (includes list_objects, describe_object)

@vercel

vercelBot commented Apr 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
objectstack-playReadyReadyPreview, CommentApr 8, 2026 9:59am
specReadyReadyPreview, CommentApr 8, 2026 9:59am

Request Review

…_metadata_object tool pairs
- Created unified `list-objects.tool.ts` (name: 'list_objects') with filter/includeFields
- Created unified `describe-object.tool.ts` (name: 'describe_object') with snake_case validation
- Deleted old `list-metadata-objects.tool.ts` and `describe-metadata-object.tool.ts`
- Removed duplicate LIST_OBJECTS_TOOL, DESCRIBE_OBJECT_TOOL from data-tools.ts
- Removed duplicate ObjectDef/FieldDef types from data-tools.ts
- DATA_TOOL_DEFINITIONS reduced from 5 to 3 (query_records, get_record, aggregate_data)
- METADATA_TOOL_DEFINITIONS retains 6 tools with unified names
- Updated metadata_assistant agent to use list_objects/describe_object
- Updated all tests across service-ai and studio
- Updated CHANGELOG.md
Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/9ed2bcd9-23a4-4f4d-b8ba-770577f41cb3
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
CopilotAI changed the title [WIP] Merge list_objects and list_metadata_objects functionalityMerge duplicate list_objects/list_metadata_objects and describe_object/describe_metadata_object toolsApr 8, 2026
CopilotAI requested a review from hotlongApril 8, 2026 09:38
@hotlong
hotlong marked this pull request as ready for review April 8, 2026 09:44
CopilotAI review requested due to automatic review settings April 8, 2026 09:44

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the duplicate list_objects/describe_object implementations that previously existed in both “data tools” and “metadata tools”, and standardizes on a single richer implementation registered via registerMetadataTools() so both data_chat and metadata_assistant share identical capabilities.

Changes:

  • Consolidated list_objects and describe_object tool metadata under unified tool definitions and removed the duplicate data-tools versions/types/handlers.
  • Simplified DATA_TOOL_DEFINITIONS to the 3 record-level tools and updated DataToolContext to no longer require metadataService.
  • Updated agents/tests/exports/changelog to use the unified tool names and new output shapes.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
packages/services/service-ai/src/tools/metadata-tools.tsSwaps tool exports/registrations to unified list_objects/describe_object.
packages/services/service-ai/src/tools/list-objects.tool.tsRenames tool metadata to list_objects (unified).
packages/services/service-ai/src/tools/describe-object.tool.tsAdds unified describe_object tool metadata file.
packages/services/service-ai/src/tools/describe-metadata-object.tool.tsRemoves the old duplicate describe_metadata_object tool metadata.
packages/services/service-ai/src/tools/index.tsUpdates tool exports to the unified names.
packages/services/service-ai/src/tools/data-tools.tsRemoves list/describe tools and drops metadataService from DataToolContext/registration.
packages/services/service-ai/src/plugin.tsUpdates registerDataTools() call site to pass only { dataEngine }.
packages/services/service-ai/src/index.tsRe-exports unified tool metadata from metadata-tools.
packages/services/service-ai/src/agents/metadata-assistant-agent.tsUpdates agent instructions/tool list to list_objects/describe_object.
packages/services/service-ai/src/tests/metadata-tools.test.tsUpdates tool names and asserts unified registration behavior.
packages/services/service-ai/src/tests/chatbot-features.test.tsUpdates tool counts and moves list/describe expectations to metadata-tool registration.
apps/studio/test/ai-chat-panel.test.tsxUpdates tool invocation part name to list_objects.
CHANGELOG.mdDocuments the tool unification and tool-definition split change.

Comment on lines 257 to 262
@@ -258,7 +258,7 @@ export class AIServicePlugin implements Plugin {
try {
const dataEngine = ctx.getService<IDataEngine>('data');
if (dataEngine && metadataService) {
registerDataTools(this.service.toolRegistry, { dataEngine, metadataService });
registerDataTools(this.service.toolRegistry, { dataEngine });
ctx.logger.info('[AI] Built-in data tools registered');

CopilotAIApr 8, 2026

Copy link

Choose a reason for hiding this comment

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

registerDataTools() no longer requires metadataService, but this block still gates data-tool registration on metadataService being present (if (dataEngine && metadataService)). This can prevent query_records/get_record/aggregate_data from being registered in runtimes where the data engine exists but metadata is unavailable. Consider registering data tools whenever dataEngine is available, and keep the agent auto-registration (which does require metadataService) behind a separate if (metadataService) check.

Copilot uses AI. Check for mistakes.
Comment on lines 289 to 294
registry: ToolRegistry,
context: DataToolContext,
): void {
registry.register(LIST_OBJECTS_TOOL, createListObjectsHandler(context));
registry.register(DESCRIBE_OBJECT_TOOL, createDescribeObjectHandler(context));
registry.register(QUERY_RECORDS_TOOL, createQueryRecordsHandler(context));
registry.register(GET_RECORD_TOOL, createGetRecordHandler(context));
registry.register(AGGREGATE_DATA_TOOL, createAggregateDataHandler(context));

CopilotAIApr 8, 2026

Copy link

Choose a reason for hiding this comment

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

registerDataTools() signature now only takes { dataEngine }, but the doc comment immediately above still states it’s called after the metadata service is available and the example passes metadataService. Update the JSDoc/example to match the new DataToolContext so callers don’t attempt to provide a non-existent dependency.

Copilot uses AI. Check for mistakes.
@hotlong

Copy link
Copy Markdown
Contributor

@copilot fix all

…stale JSDoc
- plugin.ts: Register data tools whenever dataEngine is available, not
gated on metadataService. Agent auto-registration still requires
metadataService and is nested inside a separate check.
- data-tools.ts: Update JSDoc/example to match new DataToolContext
(no longer references metadataService).
Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/f69965e4-42f5-4f19-84ef-74c854bdf5ac
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>

CopilotAI commented Apr 8, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot fix all

Fixed both review comments in 5543980:

  1. plugin.ts: Data tools (query_records, get_record, aggregate_data) are now registered whenever dataEngine is available, no longer gated on metadataService. Agent auto-registration (data_chat) remains behind a nested if (metadataService) check since it requires persistence.

  2. data-tools.ts: Updated JSDoc and example to match the new DataToolContext — no longer references metadataService.

Sign up for freeto 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.

list_objects list_metadata_objects 功能完全一致,应该合并

3 participants

@hotlong