Skip to content

RFC: Agent protocol support for apx apps#142

Open
stuart-gano wants to merge 1 commit intodatabricks-solutions:mainfrom
stuart-gano:rfc/agent-protocol
Open

RFC: Agent protocol support for apx apps#142
stuart-gano wants to merge 1 commit intodatabricks-solutions:mainfrom
stuart-gano:rfc/agent-protocol

Conversation

@stuart-gano
Copy link
Copy Markdown

@stuart-gano stuart-gano commented Mar 24, 2026

What this is

Agents are the right abstraction for custom domain knowledge in Genie Code. Genie alone can't do everything — it doesn't know your ERP schema, your billing rules, or your internal data model. But an agent can. And if you build that agent as a Databricks App, it shows up automatically in Genie Code as a custom MCP server.

This PR adds the template integration to make that first-class in APX.


Architecture

The agent runtime is a standalone pip package: apx-agent. It provides:

  • MCP endpoints/mcp (stateless HTTP for Genie Code) and /mcp/sse (SSE for Claude Desktop/Cursor)
  • A2A discovery/.well-known/agent.json with tool schemas
  • /invocations — MLflow ResponsesAgent chat endpoint with tool-calling loop
  • Tool routing — type-hinted Python functions become /api/tools/<name> routes
  • Agent composition — Sequential, Parallel, Router, Loop, Handoff patterns
  • Dev UI — chat interface, code editor, setup wizard, tool suggestion via LLM

This PR adds the thin APX template layer that wires apx-agent into the apx add agent scaffold.


What this PR changes (~1,400 lines)

Template (src/apx/templates/addons/agent/)

  • addon.toml — declares apx-agent>=0.1.0 dependency + Python AST edits for Dependencies aliases
  • pyproject.toml.jinja2 — project template with [tool.apx.agent] config section
  • agent_router.py — scaffolded tool example (what users edit)
  • agent.py — barrel re-export from apx-agent package
  • _dependency.py — ~100-line LifespanDependency shim that calls apx_agent.setup_agent()

Rust CLI

  • deploy.rsapx deploy command for Databricks Apps deployment
  • init.rs — agent addon discovery during apx init
  • build.rs / proxy.rs — agent-aware build and dev proxy

RFC doc

  • docs/rfcs/agent-protocol.md — design rationale and architecture

Integration test

  • tests/init_integration.rs — verifies apx init --addons=agent generates the right scaffold

The pattern in 5 lines

from .core import Dependencies
from .core.agent import Agent

def get_billing_summary(customer_id: str, months: int, ws: Dependencies.Client) -> dict:
    """Get a customer's recent billing history with tier breakdown and payment status."""
    rows = _run_sql(ws, f"SELECT * FROM billing_history WHERE customer_id = '{customer_id}' LIMIT {months}")
    return {"bills": rows}

agent = Agent(tools=[get_billing_summary])

APX + apx-agent handle the rest: MCP server, /invocations loop, tool routing, MLflow traces.


Where APX fits in the agent stack

MAS (Supervisor Agent) APX
Role Orchestration — routes to sub-agents Dev toolkit — builds the agents
Registration Declarative: resource IDs Code-first: Python functions
Dev loop Deploy → wait (2-5 min) uvicorn --reload (instant)

MAS is "how you wire agents together." APX is "how you build them."


Test plan

  • apx add agent generates template that imports from apx-agent
  • Deploy app named mcp-* → appears in Genie Code MCP server list
  • Genie Code agent mode calls tools via /mcp stateless HTTP
  • /mcp/sse works (Claude Desktop, Cursor)
  • /invocations works (direct API / MLflow eval)
  • All verified against explain-my-bill-agent example

@stuart-gano stuart-gano force-pushed the rfc/agent-protocol branch 3 times, most recently from 1f32a08 to e9729f3 Compare April 7, 2026 23:26
Add first-class agent support to APX — MCP endpoints, A2A discovery,
/invocations loop, tool routing, and dev UI (chat, edit, setup wizard).

The core agent runtime (tool introspection, LLM loop, MCP server,
agent composition patterns) lives in the standalone `apx-agent` package
(https://github.com/stuartgano/apx-agent). The APX template addon
imports from the package and adds the dev-mode UI layer on top.

What this changes:
- `apx add agent` scaffolds agent_router.py + dev UI
- Tools are plain Python functions with type hints
- /invocations, /.well-known/agent.json, /mcp endpoints
- Dev UI: /_apx/agent (chat), /_apx/edit (code editor), /_apx/setup (wizard)
- create_tool meta-tool for building tools via chat
- Example: explain-my-bill-agent with UC Statement Execution API
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.

1 participant