Skip to content

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

Merged
hotlong merged 3 commits intomainfrom
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 intomainfrom
copilot/merge-list-objects-and-metadata-objects

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

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
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

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

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Apr 8, 2026 9:59am
spec Ready Ready Preview, Comment Apr 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>
Copilot AI changed the title [WIP] Merge list_objects and list_metadata_objects functionality Merge duplicate list_objects/list_metadata_objects and describe_object/describe_metadata_object tools Apr 8, 2026
Copilot AI requested a review from hotlong April 8, 2026 09:38
@hotlong hotlong marked this pull request as ready for review April 8, 2026 09:44
Copilot AI review requested due to automatic review settings April 8, 2026 09:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
File Description
packages/services/service-ai/src/tools/metadata-tools.ts Swaps tool exports/registrations to unified list_objects/describe_object.
packages/services/service-ai/src/tools/list-objects.tool.ts Renames tool metadata to list_objects (unified).
packages/services/service-ai/src/tools/describe-object.tool.ts Adds unified describe_object tool metadata file.
packages/services/service-ai/src/tools/describe-metadata-object.tool.ts Removes the old duplicate describe_metadata_object tool metadata.
packages/services/service-ai/src/tools/index.ts Updates tool exports to the unified names.
packages/services/service-ai/src/tools/data-tools.ts Removes list/describe tools and drops metadataService from DataToolContext/registration.
packages/services/service-ai/src/plugin.ts Updates registerDataTools() call site to pass only { dataEngine }.
packages/services/service-ai/src/index.ts Re-exports unified tool metadata from metadata-tools.
packages/services/service-ai/src/agents/metadata-assistant-agent.ts Updates agent instructions/tool list to list_objects/describe_object.
packages/services/service-ai/src/tests/metadata-tools.test.ts Updates tool names and asserts unified registration behavior.
packages/services/service-ai/src/tests/chatbot-features.test.ts Updates tool counts and moves list/describe expectations to metadata-tool registration.
apps/studio/test/ai-chat-panel.test.tsx Updates tool invocation part name to list_objects.
CHANGELOG.md Documents 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');
Copy link

Copilot AI Apr 8, 2026

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));
Copy link

Copilot AI Apr 8, 2026

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

hotlong commented Apr 8, 2026

@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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@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.

@hotlong hotlong merged commit d22209d into main Apr 8, 2026
2 of 3 checks passed
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.

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

3 participants