Repository navigation
Implementation walkthrough for the agentic request-response + A2A/Filecoin-style demo in PR #1295 #1320
GautamBytes
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi all, opening this discussion to document the implementation details behind PR #1295 from an engineering perspective, as requested in review.
PR: #1295
Context
The goal of this work is to show how py-libp2p’s request/response foundation can support a higher-level agent workflow without changing the core
libp2p.request_responselibrary API.Instead of treating request/response as just transport, this example layers on:
The example is intentionally structured to be:
High-level structure
The implementation is split into three demo layers:
Local libp2p demo
examples/request_response/a2a_payment_demo.pyShared task/service layer
examples/request_response/a2a_payment_service.pyHTTP A2A facade
examples/request_response/a2a_http_payment_demo.pyThere is also an optional execution backend bridge:
examples/request_response/synapse_bridge.pyexamples/request_response/synapse_sidecar/Why this layering
I wanted to keep the py-libp2p transport example useful on its own while also showing how it can map into a more standards-facing agent protocol shape.
That led to this separation:
transport concern:
py-libp2p request/response handles peer-to-peer communication
workflow concern:
the shared task service handles message validation, task state transitions, quote generation, payment authorization, and artifact assembly
protocol facade concern:
the HTTP layer maps the same workflow into an A2A-style interface
This keeps the design modular and avoids pushing protocol-specific logic into the transport helper itself.
Core task lifecycle
The shared task service models the workflow using A2A-style task states.
Typical flow:
store_datamessageTASK_STATE_AUTH_REQUIREDTASK_STATE_WORKINGTASK_STATE_COMPLETEDThis gives a concrete multi-turn task flow instead of a single request/response blob.
Quote and artifact model
The quote intentionally mirrors Filecoin-style payment concepts, while remaining deterministic and local-first by default.
Quote metadata includes fields such as:
railIddepositNeededUsdfcstreamingLockupUsdfcfixedLockupUsdfcpaymentTokenoperatorvalidatorFinal task artifacts include:
1. Payment authorization artifact
Contains the approved payment rail context, payer info, and lockup values.
2. Storage receipt artifact
Contains storage execution output such as:
pieceCidDeterministic simulation backend
By default the demo uses a simulated execution backend.
This was deliberate for upstream reviewability:
The provider catalog includes healthy and unhealthy providers so the example can show both:
--copies 3That degraded path was important because I wanted the example to show realistic workflow handling under imperfect provider conditions, not just the happy path.
HTTP A2A facade
The HTTP demo reuses the same shared task service and exposes it through an A2A-shaped interface.
Main endpoints / behaviors:
GET /.well-known/agent-card.jsonPOST /rpcSendMessageGetTaskListTasksCancelTaskSendStreamingMessagevia SSEThis means the exact same workflow can be exercised in two ways:
So the example demonstrates both a transport-level integration path and a standards-facing agent interface path.
Optional Synapse bridge
The Synapse integration is intentionally optional.
The bridge is kept separate because I did not want real network/payment execution to be a hard dependency for:
When enabled explicitly, the Synapse sidecar path is intended to:
Guardrails are in place so that no real transaction execution happens unless explicitly enabled via environment configuration.
CI and implementation hygiene
A significant part of the follow-up work on this PR was making the demo robust in normal project CI environments.
That included:
The PR head is now green in CI.
What this PR does not try to do
This PR does not attempt to:
The scope is to provide a concrete, implementation-oriented example that demonstrates how these layers can fit together cleanly.
Why I think this example is useful
I believe this example is useful because it shows a realistic progression:
That makes it valuable both as:
Feedback I would especially value
I’d appreciate feedback on:
Thanks, happy to revise structure or split pieces differently if that would make the example more maintainable for the project.
All reactions