Skip to content

feat: add Restate agent example #450

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
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gvdongen
Copy link

@gvdongen gvdongen commented May 7, 2025

feat: adds a resilient reimbursement agent using Restate
This pull request introduces a new sample agent, which demonstrates how to build a resilient A2A agents using Restate.

Why?

Restate is a framework that simplifies building resilient applications. In this example, Restate acts as a scalable, resilient task orchestrator that speaks the A2A protocol and gives you a lot of resiliency features: retries, recovery, task control, idempotency, etc.

Changes

Below are the most important changes:

  • Created a README.md for the Restate reimbursement agent, explaining its features, prerequisites, setup instructions, and usage.
  • Added __main__.py to serve the Restate reimbursement agent as an A2A server.
  • Implemented the Restate equivalent of the A2A server and task manager in middleware.py
  • Implemented the core logic of the Restate agent in agent.py. This agent is identical to the Google ADK example. But now fully resilient.

How to run?

See example readme.

Note: I ran the nox formatter which caused some tool parameters (create_request_form) to change from Optional[str] to str | None causing issues with the LLM calls. This also persists with the pure Google ADK example (#422) Therefore, I reverted those types to Optional[str].

Copy link

google-cla bot commented May 7, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gvdongen gvdongen changed the title Restate a2a example feat: add Restate agent example May 7, 2025
@gvdongen gvdongen force-pushed the restate_a2a_example branch from 1fe4550 to b8fb766 Compare May 7, 2025 15:28
@zeroasterisk
Copy link
Collaborator

zeroasterisk commented May 12, 2025

Help me understand the right flow.

on a mac, I did the following setup based on your docs:

brew install restatedev/tap/restate-server restatedev/tap/restate
restate-server

Which started up:

cd samples/python/agents/restate
uv run .

Which started up the sample agent backend:

I can then register the deployment in restate server:

  • I used the restate server admin webapp and registered deployment http://localhost:9080/restate/v1 successfully

... but now I want to register that agent into my demo UI and I cannot do so:

cd demos/ui
uv run main.py

Which started up a demo UI at:

🦀 I cannot figure out what URL to register here to get the agent card of the now-protected agent into the demo.

Next: beyond protecting just one agent, it might be interesting to see the demo app be restate'ed

@gvdongen
Copy link
Author

@zeroasterisk
The flow you did looks correct. The URL you need to register in the demo UI is localhost:9080. I can add it to the readme.

Regarding the next step, yes absolutely. We initially thought of keeping this example small, self contained and similar to the other examples. We can link to more elaborate examples, that require a bit deeper familiarity with the restate concepts.

Do you have a scenario in mind? We can try it out and see how it goes.

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.

2 participants