Skip to content

Schema and tool improvements#120

Merged
ultmaster merged 10 commits intomainfrom
schema-tool-improvement
Aug 20, 2025
Merged

Schema and tool improvements#120
ultmaster merged 10 commits intomainfrom
schema-tool-improvement

Conversation

@ultmaster
Copy link
Contributor

  • Support <tool-request> and <tool-response>.
  • Rename <meta type="responseSchema"> and <meta type="tool"> to <output-schema> and <tool>.
  • Other minor improvements.

Copilot AI review requested due to automatic review settings August 20, 2025 03:52
Copy link
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 introduces support for tool request/response elements and modernizes schema/tool definitions by replacing old <meta> element patterns with dedicated elements. The changes include adding new <tool-request> and <tool-response> tags, renaming <meta type="responseSchema"> to <output-schema>, and <meta type="tool"> to <tool-definition>.

  • Support for <tool-request> and <tool-response> elements for AI tool interactions
  • Migration from <meta type="responseSchema"> and <meta type="tool"> to <output-schema> and <tool-definition>
  • Enhanced tool support in multimedia content rendering and message components

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/poml/_tags.py Adds Python bindings for tool_request and tool_response tags
packages/poml/writer.ts Implements tool request/response handling in writers and formatting improvements
packages/poml/tests/*.test.tsx Comprehensive test coverage for new tool functionality and updated element names
packages/poml/file.tsx Replaces meta element handling with dedicated schema/tool/runtime element handlers
packages/poml/essentials.tsx Adds ToolRequest and ToolResponse components to essentials library
packages/poml/components/message.tsx Updates message content handling to support tool request/response rendering
packages/poml/base.tsx Extends type definitions for tool-related multimedia content
docs/ Updates documentation to reflect new element names and tool functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const metaType = xmlAttribute(element, 'type')?.value;
if (metaType) {
this.reportError(
`Meta elements with type attribute has been removed. Use <${metaType === 'schema' ? 'output-schema' : metaType === 'tool' ? 'tool-definition' : metaType === 'runtime' ? 'runtime' : metaType}> instead of <meta type="${metaType}">`,
Copy link

Copilot AI Aug 20, 2025

Choose a reason for hiding this comment

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

[nitpick] The ternary operator chain is complex and hard to read. Consider extracting this logic into a separate function or using a map/object lookup for better maintainability.

Suggested change
`Meta elements with type attribute has been removed. Use <${metaType === 'schema' ? 'output-schema' : metaType === 'tool' ? 'tool-definition' : metaType === 'runtime' ? 'runtime' : metaType}> instead of <meta type="${metaType}">`,
// Map old meta types to new tag names
const metaTypeToTag: { [key: string]: string } = {
schema: 'output-schema',
tool: 'tool-definition',
runtime: 'runtime'
};
const replacementTag = metaTypeToTag[metaType] || metaType;
this.reportError(
`Meta elements with type attribute has been removed. Use <${replacementTag}> instead of <meta type="${metaType}">`,

Copilot uses AI. Check for mistakes.
speaker={speaker ?? 'ai'}
data={{ id, name, parameters }}
{...others}
/>
Copy link

Copilot AI Aug 20, 2025

Choose a reason for hiding this comment

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

[nitpick] The fallback rendering in ToolRequest component renders the tool request as a generic Object. This could be confusing for users since it doesn't clearly indicate it's a tool request. Consider providing a more descriptive fallback or throwing an error with guidance.

Suggested change
/>
<div
style={{
border: '1px solid #ccc',
borderRadius: 4,
padding: 12,
background: '#f9f9f9',
color: '#333',
margin: '8px 0'
}}
{...others}
>
<strong>Tool Request</strong>
<div><strong>ID:</strong> {id ?? <em>None</em>}</div>
<div><strong>Name:</strong> {name ?? <em>None</em>}</div>
<div>
<strong>Parameters:</strong>
<pre style={{ margin: 0, background: 'none', padding: 0 }}>
{parameters ? JSON.stringify(parameters, null, 2) : <em>None</em>}
</pre>
</div>
<div style={{ color: '#b00', marginTop: 8, fontSize: 12 }}>
(Fallback rendering: ToolRequest could not be rendered in the current syntax context.)
</div>
</div>

Copilot uses AI. Check for mistakes.
@ultmaster ultmaster merged commit 3a4d102 into main Aug 20, 2025
7 checks passed
@ultmaster ultmaster deleted the schema-tool-improvement branch August 27, 2025 00:53
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.

2 participants