Skip to content

Commit 2e06fa4

Browse files
authored
Merge pull request #151 from LauJoeYing/acp/joey-add-job-expiry-usage-example
[ACP] [Docs] Add Usage Guide for `job_expiry_duration_mins` in ACP Plugin Setup
2 parents 72e2103 + 9c2d231 commit 2e06fa4

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

plugins/acp/examples/agentic/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,47 @@ Clusters help with:
239239

240240
When configuring your agent, choose clusters that accurately represent your agent's capabilities to ensure it can be found by the right counterparts.
241241

242+
## Job Expiry Setup with `job_expiry_duration_mins`
243+
244+
The `job_expiry_duration_mins` parameter defines how long a job request remains active and valid before it automatically expires. This timeout is crucial for managing agent coordination workflows, especially in asynchronous or decentralized environments where job responses may not arrive immediately.
245+
246+
### Why It Matters
247+
248+
Setting an expiry time ensures that:
249+
- Stale or unresponsive job requests do not hang indefinitely
250+
- The system can safely discard or retry expired jobs
251+
252+
### How It Works
253+
Internally, `job_expiry_duration_mins` is used to compute a future timestamp (expired_at) relative to the current time:
254+
```bash
255+
expired_at = datetime.now(timezone.utc) + timedelta(minutes=self.job_expiry_duration_mins)
256+
```
257+
258+
### Example: Plugin Setup with Job Expiry
259+
```python
260+
acp_plugin = AcpPlugin(
261+
options=AcpPluginOptions(
262+
api_key=os.environ.get("GAME_DEV_API_KEY"),
263+
acp_token_client=AcpToken(
264+
os.environ.get("ACP_TOKEN_BUYER"),
265+
os.environ.get("ACP_AGENT_WALLET_ADDRESS_BUYER"),
266+
"https://base-sepolia-rpc.publicnode.com/",
267+
"https://acpx-staging.virtuals.io/api"
268+
),
269+
cluster="hedgefund",
270+
on_evaluate=on_evaluate,
271+
on_phase_change=on_phase_change,
272+
job_expiry_duration_mins = 10 #Job will expire 10 minutes after creation
273+
)
274+
)
275+
```
276+
277+
In this example:
278+
- Any job created through this plugin instance will be automatically marked as expired after 10 minutes, unless a response is received.
279+
- You can adjust this value (e.g., to 20 or 30) based on how responsive your agent network is.
280+
281+
---
282+
242283
## Note
243284

244285
- Make sure to replace placeholder API keys and private keys with your own

plugins/acp/examples/reactive/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,47 @@ Clusters help with:
385385

386386
When configuring your agent, choose clusters that accurately represent your agent's capabilities to ensure it can be found by the right counterparts.
387387

388+
## Job Expiry Setup with `job_expiry_duration_mins`
389+
390+
The `job_expiry_duration_mins` parameter defines how long a job request remains active and valid before it automatically expires. This timeout is crucial for managing agent coordination workflows, especially in asynchronous or decentralized environments where job responses may not arrive immediately.
391+
392+
### Why It Matters
393+
394+
Setting an expiry time ensures that:
395+
- Stale or unresponsive job requests do not hang indefinitely
396+
- The system can safely discard or retry expired jobs
397+
398+
### How It Works
399+
Internally, `job_expiry_duration_mins` is used to compute a future timestamp (expired_at) relative to the current time:
400+
```bash
401+
expired_at = datetime.now(timezone.utc) + timedelta(minutes=self.job_expiry_duration_mins)
402+
```
403+
404+
### Example: Plugin Setup with Job Expiry
405+
```python
406+
acp_plugin = AcpPlugin(
407+
options=AcpPluginOptions(
408+
api_key=os.environ.get("GAME_DEV_API_KEY"),
409+
acp_token_client=AcpToken(
410+
os.environ.get("ACP_TOKEN_BUYER"),
411+
os.environ.get("ACP_AGENT_WALLET_ADDRESS_BUYER"),
412+
"https://base-sepolia-rpc.publicnode.com/",
413+
"https://acpx-staging.virtuals.io/api"
414+
),
415+
cluster="hedgefund",
416+
on_evaluate=on_evaluate,
417+
on_phase_change=on_phase_change,
418+
job_expiry_duration_mins = 10 #Job will expire 10 minutes after creation
419+
)
420+
)
421+
```
422+
423+
In this example:
424+
- Any job created through this plugin instance will be automatically marked as expired after 10 minutes, unless a response is received.
425+
- You can adjust this value (e.g., to 20 or 30) based on how responsive your agent network is.
426+
427+
---
428+
388429
## Note
389430

390431
- Make sure to replace placeholder API keys and private keys with your own

0 commit comments

Comments
 (0)