Skip to content

[week-06] 25512089 - #290

Open
ChanArun wants to merge 8 commits into
Q00:mainfrom
ChanArun:week-06
Open

ChanArun wants to merge 8 commits into
Q00:mainfrom
ChanArun:week-06

Conversation

@ChanArun

@ChanArun ChanArun commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What I built

I implemented an A2A v1.0 seller and buyer using a custom Python harness backed by GroqCloud openai/gpt-oss-120b.

The harness makes negotiation decisions, while Python handles A2A communication and enforces hard safety constraints such as seller reserves and buyer budgets.

Base assignment

The seller exposes an A2A v1.0 Agent Card, uses JSON-RPC, keeps the required reserves for lamp, chair, and bookshelf, returns TASK_STATE_INPUT_REQUIRED during negotiation, continues follow-up messages on the same taskId, and returns a structured receipt artifact with a numeric price when a deal completes.

The buyer reads the seller Agent Card, selects the JSON-RPC v1.0 interface, sends A2A-Version: 1.0, continues negotiation using the same taskId, never offers above its budget, and stops when the harness decides that no acceptable deal is possible.

The harness decides seller opening asks, counteroffers, accept/reject decisions, buyer offers, and walk-away decisions. The Python code additionally enforces seller reserve and buyer budget as hard boundaries.

Base result

21/21 passed -> PASS
all checks passed

Required Challenge 1 — Large catalog seller

I generated and committed a synthetic catalog containing 4,000 products. Instead of sending the full catalog to the model, the system uses this pipeline:

buyer natural-language request
-> harness extracts structured search criteria
-> Python searches 4,000 products
-> at most 8 candidates remain
-> harness selects the product and opening price
-> A2A negotiation continues

Recorded successful case:

[CHALLENGE1 SEARCH] catalog_size=4000 candidate_count=8
[CHALLENGE1 SELECTION] sku=ARUN-3001 name='Modern Wood Bookshelf 3001' reserve=114 ask=130
[CHALLENGE1 DEAL] price=120 reserve=114

The final sale price stayed above reserve.

I also tested an impossible request for a bamboo bookshelf with strict height/capacity constraints. The search returned zero candidates and the seller rejected the request instead of choosing the wrong product.

Evidence is stored in:

logs/challenge-1/

Required Challenge 2 — Many shops and one total budget

I created 20 A2A shops with different inventories, reserves, and advertised prices. The buyer reads all 20 Agent Cards, builds a shop directory, asks the harness to choose shops and item-level budgets, and then negotiates with selected shops concurrently.

Recorded shopping list:

lamp
chair
side table

Total budget: 450

Harness plan:

lamp       -> shop-05 -> budget 100
chair      -> shop-04 -> budget 160
side table -> shop-14 -> budget 120
allocated total = 380 / 450

Each negotiation maintains its own taskId, task state, item budget, turn number, latest seller price, a compact state summary, and only the two most recent messages.

Recorded purchases:

chair      -> shop-04 -> price 150 / budget 160
lamp       -> shop-05 -> price 85  / budget 100
side table -> shop-14 -> price 90  / budget 120

Final verification:

[CHALLENGE2 VERIFY] cards=20 items=3/3 distinct_shops=3 total_spend=325/450 duplicates=0
[CHALLENGE2] PASS

Therefore all 20 Agent Cards were read, all 3 requested items were purchased from 3 different shops, no item was duplicated, and total spending stayed within the global budget.

Evidence is stored in:

logs/challenge-2/

What I tried and fixed

During development, the first seller implementation used an SDK call that was incompatible with the installed A2A SDK:

TaskUpdater.update_status() got an unexpected keyword argument 'final'

I replaced it with the SDK's requires_input(...) helper for TASK_STATE_INPUT_REQUIRED.

Another manual run produced:

Error: failed to send message: Error code: 400

I hardened the custom harness with API retries, JSON extraction/recovery, semantic validation retries, seller-reserve enforcement, and buyer-budget enforcement. After the fixes, the official trade test passed 21/21.

What A2A fixed and what remained outside A2A

A2A standardized Agent Card discovery, JSON-RPC communication, protocol versioning, taskId continuation, task states, and structured completion artifacts.

A2A did not define the business semantics of negotiation, so the agents still had to agree on item representation, numeric offers, current asking price, acceptance meaning, and receipt fields.

Harness

  • Provider: GroqCloud
  • Model: openai/gpt-oss-120b
  • API style: OpenAI-compatible API
  • Base URL: https://api.groq.com/openai/v1
  • Temperature: 0
  • A2A SDK: a2a-sdk 1.2.2
  • API key is supplied through OPENAI_API_KEY and is not committed.

Validation summary

Validation Result
Official base trade test 21/21 PASS
check_week06.py PASS
Challenge 1 catalog size 4,000 products
Challenge 1 candidates 8 or fewer
Challenge 1 successful deal 120, reserve 114
Challenge 1 impossible request Rejected
Challenge 2 Agent Cards 20/20
Challenge 2 items 3/3 purchased
Challenge 2 distinct shops 3
Challenge 2 total spend 325/450
Duplicate purchases 0

How to run

From the repository root:

python scripts\trade_test_week06.py submissions\25512089\week-06
python scripts\check_week06.py submissions\25512089\week-06

Challenge 1 seller:

python challenge1_seller.py --port 9201

Challenge 2:

python run_challenge2_shops.py
python check_challenge2_shops.py
python challenge2_buyer.py

Limitations

Challenge 2 currently plans shop selection and item budgets before negotiations start and does not perform a second global re-planning step if a selected shop later fails. Exact model-generated offers may vary between runs because the harness uses an external model service.

Challenge 3, deployment, and cross-student trading were not included because they are optional / extra credit.

Checklist

  • Implemented model-driven A2A v1.0 seller
  • Implemented model-driven A2A buyer with budget enforcement
  • Passed official base trade test: 21/21
  • Implemented Agent Card, JSON-RPC, same-task negotiation, version header, and receipt artifacts
  • Completed Required Challenge 1: 4,000-product large catalog
  • Completed Required Challenge 2: 20 shops, shopping list, concurrent negotiation, and total-budget enforcement

Additional verification:

  • check_week06.py: all checks passed
  • Challenge 1 success and no-match logs are committed
  • Challenge 2 buyer and shop logs are committed
  • Challenge 2 duplicate purchases: 0
  • Challenge 2 spend: 325/450
  • No API key or token is committed
  • PR changes are limited to submissions/25512089/week-06/

This branch has not been deployed

No deployments
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