Skip to content

Conversation

OskarStark
Copy link
Contributor

@OskarStark OskarStark commented Oct 2, 2025

Q A
Bug fix? no
New feature? yes
Docs? yes
Issues --
License MIT

@carsonbot carsonbot added Status: Needs Review Bug Something isn't working Feature New feature labels Oct 2, 2025
@carsonbot carsonbot changed the title Oskar stark/platforms as tools Oskar stark/platforms as tools Oct 2, 2025
@OskarStark
Copy link
Contributor Author

Any idea @chr-hertel ?

CleanShot 2025-10-02 at 16 12 15@2x

@OskarStark OskarStark changed the title Oskar stark/platforms as tools [Agent] Add Platform tool wrapper for using platforms as tools Oct 2, 2025
@OskarStark OskarStark marked this pull request as draft October 2, 2025 14:20
@chr-hertel
Copy link
Member

maybe the options argument? not sure

@OskarStark
Copy link
Contributor Author

No, even removing the options does not help

@chr-hertel
Copy link
Member

Best would be Xdedump i guess

Comment on lines +41 to +45
return $this->platform->invoke(
$this->model,
$message,
$this->options,
)->asText();
Copy link
Member

Choose a reason for hiding this comment

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

check for instanceof TextResult and handle other cases. at least ObjectResult can be json serialized

Comment on lines +410 to +422
$count = 0;
if (!empty($v['agent'])) {
++$count;
}
if (!empty($v['service'])) {
++$count;
}
if (!empty($v['platform'])) {
++$count;
}

return 1 !== $count;
Copy link
Member

Choose a reason for hiding this comment

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

ha nice, that's pragmatic 👍

Comment on lines +393 to +398
->stringNode('model')->cannotBeEmpty()->end()
->arrayNode('options')
->info('Options to pass to the platform')
->scalarPrototype()->end()
->end()
Copy link
Member

Choose a reason for hiding this comment

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

can we validate that model and options is only allowed in combination with platform? or do i get it wrong?

Introduces a new Platform tool that wraps any PlatformInterface instance,
allowing agents to use specialized platforms as tools. This enables
scenarios like an OpenAI agent using ElevenLabs for speech-to-text.

- Add Platform tool class with support for Text, Audio, and Image results
- Add OpenAI example demonstrating ElevenLabs platform as tool
- Add documentation explaining the concept and usage
- Update demo AI Bundle configuration with platform tool examples
Platforms can now be configured as tools in agent definitions:

ai:
  agent:
    my_agent:
      tools:
        - platform: 'elevenlabs'
          model: 'scribe_v1'
          name: 'transcribe_audio'
          description: 'Transcribes audio files to text'
          options: []

This allows agents to use specialized platforms as tools, enabling
scenarios like an OpenAI agent using ElevenLabs for speech-to-text.
Removed explicit await() and result type matching by using the
ResultPromise::asText() convenience method which handles the
await internally and extracts text content directly.
Updated platform-as-tool.php to follow the same pattern as agent-as-tool.php:
- Use MemoryToolFactory to register tool with name and description
- Use ChainFactory to combine MemoryToolFactory and ReflectionToolFactory
- Provides better tool metadata for the agent
Changed from ElevenLabs speech-to-text example to a simpler OpenAI-only
example that mirrors the agent-as-tool pattern:
- Main agent uses gpt-4o-mini
- Platform tool uses gpt-4o for advanced analysis
- Demonstrates using a more powerful model as a tool for complex tasks
- Removes external dependency on ElevenLabs API key
Changed from complex philosophical question to the same simple math
question used in agent-as-tool.php for consistency and clarity.
- Removed ElevenLabs reference from docblock example
- Updated example to use gpt-4o/gpt-4o-mini scenario
- Fixed parameter name from $message to $input to match signature
@OskarStark OskarStark force-pushed the OskarStark/platforms-as-tools branch from ec5c747 to ee38c77 Compare October 7, 2025 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Feature New feature Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants