Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@dannon
Copy link
Member

@dannon dannon commented Dec 11, 2025

Pull Request: AI Agent Framework for Galaxy

Summary

This PR introduces an AI-powered multi-agent framework for Galaxy. The focus is on establishing the framework and APIs - the agents themselves are functional but will continue to evolve, and of course we want to add more. This provides the foundation for intelligent assistance in error analysis, tool recommendations, custom tool creation, and training material discovery. This is NOT meant to be merged as-is -- we want to iterate on the framework and basic agents with a wider audience and this will likely be trimmed down prior to merge. The GTN agent works well and is useful, but I don't love the deployment mechanism and we want to use chatgxy-materials embeddings (likely) anyway, which can happen in a separate branch.

Key Points

  • Framework-first approach: The core value here is the infrastructure - agent base classes, registry, service layer, API endpoints, and configuration system. Individual agents will improve over time.
  • Dual API surface: Both conversational (/api/chat) and direct programmatic access (/api/ai/agents/*) endpoints
  • Flexible configuration: Per-agent model/temperature settings with sensible defaults
  • Model-agnostic: Works with OpenAI, Anthropic, Google, and local models (vLLM, Ollama)

What's Included

Framework Components

  • lib/galaxy/agents/base.py - Base agent classes with pydantic-ai integration
  • lib/galaxy/agents/registry.py - Dynamic agent registration and lookup
  • lib/galaxy/managers/agents.py - Centralized AgentService for execution
  • lib/galaxy/schema/agents.py - Pydantic API schemas

API Endpoints

  • GET /api/ai/agents - List available agents
  • POST /api/ai/agents/query - Unified query with auto-routing
  • POST /api/ai/agents/error-analysis - Direct error analysis
  • POST /api/ai/agents/tool-recommendation - Direct tool recommendations
  • POST /api/ai/agents/custom-tool - Direct custom tool creation
  • Enhanced /api/chat for ChatGXY

Initial Agents (5)

  1. Router - Analyzes user queries and routes them to the appropriate specialist agent. Uses intent classification to determine whether someone needs help debugging, finding tools, learning, etc.
  2. Error Analysis - Examines job failures, stderr output, and tool context to diagnose what went wrong and suggest fixes. Can recommend alternative tools if the current one isn't suitable.
  3. Tool Recommendation - Helps users find the right Galaxy tool for their analysis task. Searches the toolbox and provides guidance on parameters and usage.
  4. Custom Tool - Generates Galaxy tool XML/YAML definitions from natural language descriptions. Useful for wrapping command-line tools or scripts.
  5. GTN Training Helper - Searches the Galaxy Training Network using full-text search to find relevant learning materials for any topic.

UI Integration

  • ChatGXY as full-page activity in activity bar
  • GalaxyWizard integration for error analysis
  • Action suggestions with interactive buttons

Configuration

# Minimal - uses defaults (this is the pre-existing config options)
ai_api_key: ${OPENAI_API_KEY}
ai_model: gpt-4o-mini

# Or new per-agent configuration falling back to 'default'
inference_services:
  default:
    model: "llama-4-scout"
    api_key: "sk-local-test-master-key"
    api_base_url: "http://localhost:4000/v1/"
    temperature: 0.7
    max_tokens: 2000
  custom_tool:
    model: "anthropic:claude-sonnet-4-5"
    api_key: "sk-ant-api03-SUPERSECRETKEY"

What's NOT Included (Future Work)

  • Dataset analyzer agent (Junhao has a branch based on this one using this framework to implement it)
  • MCP (Model Context Protocol) integration - separated into galaxy-mcp branch
  • Workflow generation from natural language
  • Per-user API key management
  • Additional specialized agents

Testing

  • To make this easy, we plan to deploy on test and will allow folks to primarily exercise it that way.

  • There is a start of a comprehensive pytest suite with mocked and live LLM modes

  • mypy and lint checks passing

  • Tested with claude (sonnet and haiku) and local LLMs via LiteLLM

# Run mocked tests
pytest lib/galaxy_test/api/test_agents.py -k Mocked -v

# Run live LLM tests
GALAXY_TEST_ENABLE_LIVE_LLM=1 pytest lib/galaxy_test/api/test_agents.py -k LiveLLM -v

Notes

  • The GTN search database (gtn_search.db) needs to be built at deployment time - not included in repo (well, it is now, as John noticed, but it won't be)
  • Agents gracefully handle models without structured output support

lib/galaxy/agents/orchestrator.py Dismissed Show dismissed Hide dismissed
lib/galaxy/agents/orchestrator.py Dismissed Show dismissed Hide dismissed
lib/galaxy/webapps/galaxy/api/chat.py Fixed Show fixed Hide fixed
client/src/entry/analysis/router.js Show resolved Hide resolved
client/webpack.config.js Outdated Show resolved Hide resolved
Returns:
List of tool categories
"""
return [
Copy link
Member

Choose a reason for hiding this comment

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

I'd love to see these agents come in one at a time after the framework - I would feel better critiquing them in that context. If the cost of getting the infrastructure in is this though - I guess I'm fine - I would love to see progress and we could clean this up later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's totally fine, we just have to have some set of things to test initially. Plan is to prune it down and open separate PRs.

lib/galaxy_test/api/test_agents.py Outdated Show resolved Hide resolved
lib/galaxy_test/driver/driver_util.py Outdated Show resolved Hide resolved
@jmchilton
Copy link
Member

Binary file addedBIN +24.8 MB
lib/galaxy/agents/gtn/data/gtn_search.db

I think this is still in and the PR description says it is out?

@dannon
Copy link
Member Author

dannon commented Dec 11, 2025

Binary file addedBIN +24.8 MB lib/galaxy/agents/gtn/data/gtn_search.db

I think this is still in and the PR description says it is out?

It is for now so folks don't have to build it. It'll be rebased out (probably along with the agent itself, to be included separately)

lib/galaxy/agents/prompts/custom_tool_text.md Outdated Show resolved Hide resolved
@dannon dannon closed this Dec 11, 2025
@dannon dannon reopened this Dec 11, 2025
@dannon dannon force-pushed the agent-based-ai branch 3 times, most recently from e65c242 to 643ec7c Compare December 11, 2025 15:56
@jmchilton
Copy link
Member

I've pushed 967ba75 that makes some changes to the tests. Please feel free to rebase or squash it as much as you'd like. I've removed some tests to get things green but I've tracked them in #21437.

There are many parts of the code that do unqualified imports of pydantic-ai - I think it really needs to be a hard dependency. For instance pytest collection fails the way things are now (https://github.com/galaxyproject/galaxy/actions/runs/20148161399/job/57834129303?pr=21434). Also I needed to install some pytest asyncio library to get these tests to run that will probably need to be dev dependency - I guess CI will make that clear.

I think the remaining tasks:

  • Client linting.
  • Fix dependencies (pydantic-ai should be unconditional).
  • Make the APIs as beta and for consumption only by the UI.
  • Drop GTN agent (restore in a separate PR after this is merged).
  • Drop tool recommendation agent (restore in a separate PR after this merged).

lib/galaxy/agents/base.py Outdated Show resolved Hide resolved
lib/galaxy/agents/base.py Show resolved Hide resolved
lib/galaxy/agents/base.py Outdated Show resolved Hide resolved
@dannon dannon force-pushed the agent-based-ai branch 4 times, most recently from bcce7d5 to 306dae4 Compare December 19, 2025 20:20
- Move unit tests out of integration test file and into test/unit.
- Move remaining "API" tests into test/integration because they use ``self.app`` and mock out the API - they are what we would call integration tests in Galaxy.
- Have unit and integration tests use the same common environment variables all now prefixed with GALAXY_TEST_ (we do this for object store stuff).
- Small tweak to orchestrator.py to make the unit tests pass.
- Clean up the mocked tests method to work cleanly without any infrastructure - some tests that used the LLM had gotten in there. Tracked the tests I removed as galaxyproject#21437.
Changed the agent endpoints to return proper AgentResponse types instead of Dict[str, Any], which gives us typed responses in the client. Updated execute_agent in the manager to return the schema object directly. Fixed type assertion in GalaxyWizard for accessing metadata.error.
route_and_execute now returns AgentResponse instead of dict, fixed the
dict-style access that was breaking agent queries. Also added unused-ignore
to type comments so mypy passes whether or not pydantic_ai is installed.
Added pytestmark_live_llm to unittest_utils for skipping live LLM tests.
Added importorskip for pydantic_ai in unit tests so they skip gracefully
when the optional dependency isn't installed.
- Add get_agent callable to GalaxyAgentDependencies to avoid circular
  imports when agents call other agents via tool functions. A bit more
  contrived than the late import it replaces, but may be strictly cleaner
  architecturally.
- Replace regex-based agent_type derivation with explicit class attribute
  requirement for clarity
- Improve _validate_model_capabilities docstring
Tool-rec code was too entangled across commits to cleanly rebase out,
so just deleting the files and updating references instead.

The agent-based-ai-tool-rec branch has the full implementation for
a follow-up PR.
The GTN agent was extracted to agent-based-ai-gtn branch previously,
but references remained in tests and prompts. Cleaning those up now.
Move pydantic-ai from conditional to required dependencies since the
agents code imports it unconditionally.
Replace str(e) in user-facing responses with generic error messages.
The detailed exception info is still logged server-side for debugging.
Fixes protobuf version conflict for Python 3.9 (temporalio requires
protobuf<6) and picks up a few minor version bumps.
Since pydantic-ai is now a required dependency, remove all the
HAS_PYDANTIC_AI conditional checks and simplify the imports.
Also fix ModelRequest/ModelResponse construction to use proper
parts-based API.
Use proper pydantic-ai types and APIs, fix list typing in chat
history, correct Agent.run_sync() usage. Add generic type parameters
to Agent class attributes and fix provider variable naming in base.py.
Match base class Agent[GalaxyAgentDependencies, Any] signature.
Output types vary at runtime based on model structured output support.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.