[Hackathon] Add OpenRouter AI Agent operator#5111
Draft
ImJordanNetz wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Demo: https://youtu.be/AyJ_fjezdx8
The Story
Texera users often want to enrich rows with AI: classify support tickets, extract fields from PDFs, summarize web pages, tag biomedical notes, or normalize messy text before downstream analysis.
Today, doing that inside a workflow usually means leaving Texera, writing custom scripts, manually calling an LLM API, then bringing the results back. That breaks the workflow model. It also makes common AI enrichment tasks hard to reuse, hard to configure, and hard to run row-by-row at scale.
What if users could drag an AI operator onto the canvas, choose a model, select input columns, optionally enable tools, and produce structured output directly in the workflow?
What We Built
An OpenRouter-backed AI Agent operator for Texera workflows. It lets users call modern LLMs row-by-row, emit text or structured columns, estimate per-row cost, capture errors, and optionally let the model use URL/PDF/MCP tools.
AI Agent Operator
New workflow operator: AI Agent
Users can configure:
OpenRouter Model Selector
The property editor includes a searchable OpenRouter model selector:
OPENROUTER_API_KEYStructured Output
Users can define output columns directly in the operator config.
Example fields:
The agent is forced to return a final structured result, and Texera appends those fields as normal output columns.
Tool Use
The operator supports built-in tools:
read_urlfetches public web pages and returns cleaned Markdownread_pdfextracts text from public PDF URLsMCP servers can also be configured so external tools appear as namespaced model-callable tools.
Safety and Reliability
This PR also hardens the implementation:
How It Works Under the Hood
The operator is implemented as a standard Texera map operator.
For each input row:
_cost_usdand_errorcolumns are appended.The operator uses Texera's existing schema propagation and execution infrastructure, so downstream operators see normal columns.
Demo
Open a workflow and add AI Agent.
Example:
review_textstructuredsentimentreasonopenai/gpt-4o-miniRun the workflow. Each input row is enriched with AI-generated structured output.
Testing
sbt clean compilesbt "WorkflowOperator / Test / compile" "AccessControlService / Test / compile"sbt "WorkflowOperator / testOnly org.apache.texera.amber.operator.aiagent.AIAgentResponseCacheSpec org.apache.texera.amber.operator.aiagent.AIAgentUrlSafetySpec org.apache.texera.amber.operator.aiagent.AIAgentOutputParserSpec org.apache.texera.amber.operator.aiagent.AIAgentOpDescSpec"sbt "AccessControlService / testOnly org.apache.texera.OpenRouterModelsResourceSpec"git diff --check