forked from ag-ui-protocol/ag-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: support new integration: Open Agent Spec #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sonleoracle
wants to merge
2
commits into
main
Choose a base branch
from
sonleoracle/feat-support-agent-spec
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,260
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| Open Agent Spec <> AG‑UI (Python) | ||
| ================================= | ||
|
|
||
| Agent runner that emits AG‑UI events and a small FastAPI/uvicorn server to stream them to Dojo via SSE. | ||
|
|
||
| What this is | ||
| - Agent runner: `ag_ui_agentspec/agent.py` executes an Agent Spec configuration on a chosen runtime and bridges spans to AG‑UI events. | ||
| - Server wiring: `ag_ui_agentspec/endpoint.py` exposes a POST SSE endpoint that streams those events to the Dojo frontend. | ||
|
|
||
| Supported agent runtimes and Dojo features | ||
| - Wayflow (Oracle's reference agent framework) (chat, frontend tools, backend tools) | ||
| - LangGraph (chat, frontend tools, backend tools, tool call streaming) | ||
|
|
||
| ## Install | ||
|
|
||
| Base library plus optional extras so you can choose runtimes. Routers are lazy-loaded; if you don't install a runtime, its routes will not work. | ||
|
|
||
| Before installation, please clone the following GitHub repositories: | ||
| - [AG-UI](https://github.com/ag-ui-protocol/ag-ui) and `cd ag-ui/integrations/agent-spec/python` | ||
| - [Agent Spec](https://github.com/oracle/agent-spec) | ||
| - [WayFlow](https://github.com/oracle/wayflow) | ||
| - Please put these 3 repos in the same directory. | ||
|
|
||
|
|
||
| ```bash | ||
| # Wayflow only | ||
| uv pip install -e .[wayflow] | ||
|
|
||
| # LangGraph only | ||
| uv pip install -e .[langgraph] | ||
|
|
||
| # Multiple | ||
| uv pip install -e .[wayflow,langgraph] | ||
| ``` | ||
|
|
||
| Run the example server | ||
| ```bash | ||
| cd ag-ui/integrations/agent-spec/python/examples | ||
| uv sync --extra langgraph --extra wayflow && uv run dev # both runtimes; serves http://localhost:9003 | ||
| # or pick one runtime: | ||
| # uv sync --extra langgraph && uv run dev | ||
| # uv sync --extra wayflow && uv run dev | ||
| # then run Dojo (in a separate terminal): | ||
| # Option A — run everything from repo root (multiple apps): | ||
| # pnpm turbo run dev | ||
| # Option B — run only Dojo: | ||
| # cd ag-ui/apps/dojo | ||
| # AGENT_SPEC_URL=http://localhost:9003 pnpm dev (make sure to run pnpm build first) | ||
| ``` | ||
|
|
||
| Environment | ||
| - OpenAI-compatible variables commonly used by the examples (pick your provider): | ||
| - `OPENAI_BASE_URL` (or provider-specific: `OSS_API_URL`, `LLAMA_API_URL`, etc.) | ||
| - `OPENAI_MODEL` (the model slug, defaults to `gpt-4o` availble through OpenAI API) | ||
| - `OPENAI_API_KEY` | ||
| - Dojo server URL: | ||
| - `AGENT_SPEC_URL=http://localhost:9003` when running the local example server |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from ag_ui_agentspec.endpoint import add_agentspec_fastapi_endpoint | ||
|
|
||
| __all__ = [ | ||
| "add_agentspec_fastapi_endpoint", | ||
| ] |
sonleoracle marked this conversation as resolved.
Show resolved
Hide resolved
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from typing import Literal | ||
|
|
||
| from ag_ui.core import RunAgentInput | ||
| from ag_ui_agentspec.agentspec_tracing_exporter import AgUiSpanProcessor | ||
| from pyagentspec.tracing.trace import Trace | ||
| from pyagentspec.tracing.spans.span import Span | ||
| from ag_ui_agentspec.agentspecloader import load_agent_spec | ||
|
|
||
|
|
||
| class AgentSpecAgent: | ||
| def __init__( | ||
| self, | ||
| agent_spec_config: str, | ||
| runtime: Literal["langgraph", "wayflow"], | ||
| tool_registry=None, | ||
| additional_processors=None | ||
| ): | ||
| if runtime not in {"langgraph", "wayflow"}: | ||
| raise NotImplementedError("other runtimes are not supported yet") | ||
| self.runtime = runtime | ||
| self.framework_agent = load_agent_spec(runtime, agent_spec_config, tool_registry) | ||
| self.processors = [AgUiSpanProcessor(runtime=runtime)] + (additional_processors or []) | ||
|
|
||
| async def run(self, input_data: RunAgentInput) -> None: | ||
| agent = self.framework_agent | ||
| async with Trace(name="ag-ui run wrapper", span_processors=self.processors): | ||
| async with Span(name="invoke_graph"): | ||
| if self.runtime == "langgraph": | ||
| from ag_ui_agentspec.runtimes.langgraph_runner import run_langgraph_agent | ||
| await run_langgraph_agent(agent, input_data) | ||
| elif self.runtime == "wayflow": | ||
| from ag_ui_agentspec.runtimes.wayflow_runner import run_wayflow | ||
| await run_wayflow(agent, input_data) | ||
| else: | ||
| raise NotImplementedError(f"Unsupported runtime: {self.runtime}") |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.