From a2167b90124dee8ea52b36213bf3e78f76a8481d Mon Sep 17 00:00:00 2001 From: Josh Mabry Date: Fri, 6 Nov 2026 00:32:11 -0800 Subject: [PATCH 1/2] fix: pricing needs a comps source; chat sales go to mark_sold, not the paste tool (0.16.4) Price the sell pile on an agent without the ebay plugin (a Merchant archetype agent) started a turn with no comps tool: at best everything came back unpriced, at worst it burned turns on web searches. start_pricing now checks sdk.config().plugins_enabled and, without ebay, closes the pricing at once with every piece unpriced and the reason (Set price by hand). An unknown host keeps the old behavior. The tool-selection eval showed both gateway models picking the turn-only inventory_sale_candidates first for a chat "sold the X for $Y". Its description now scopes it to the view's paste-a-sale turns and sends chat sales to inventory_list / inventory_get and inventory_mark_sold. Re-run: fast 81.1% -> 86.8% (sale 0/5 -> 3/5), smart 90.6% (sale 1/5 -> 3/5), turn-only picks 0 on both; the rest are read-before-acting. Co-Authored-By: Claude Opus 5.5 --- docs/upgrading.md | 13 ++++++++++ evals/tool_selection/README.md | 15 ++++++++++++ protoagent.plugin.yaml | 2 +- pyproject.toml | 2 +- scans.py | 29 ++++++++++++++++++++++ tests/test_scans.py | 44 ++++++++++++++++++++++++++++++++++ tools.py | 2 +- 7 files changed, 104 insertions(+), 3 deletions(-) diff --git a/docs/upgrading.md b/docs/upgrading.md index 0f2c777..59da3df 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -4,6 +4,19 @@ Version notes that change behavior, newest first. Installing or updating through database migrations for you: every one is additive, and an older database upgrades in place on first open. Take a copy of `inventory.db` before a big jump anyway. +## 0.16.4 + +- **Price the sell pile needs a comps source.** Without the ebay plugin enabled, it no longer starts an + agent turn: every piece comes back unpriced with the reason, so you set prices by hand with **Set + price**. With the plugin enabled, nothing changes. +- **The agent records a sale you mention in chat with `inventory_mark_sold`.** The sale-candidates tool + is scoped to the view's paste-a-sale turns, which a tool-selection eval showed both gateway models + were wrongly reaching for. + +## 0.16.3 + +- **A tool-selection eval** in `evals/tool_selection/`. No behavior change. + ## 0.16.2 - **Docs only.** The README and `docs/` follow the protoAgent plugin docs standard, and the agent skill diff --git a/evals/tool_selection/README.md b/evals/tool_selection/README.md index a2a55d8..da4752b 100644 --- a/evals/tool_selection/README.md +++ b/evals/tool_selection/README.md @@ -47,3 +47,18 @@ picked it first for "sold the X for $Y" prompts, instead of `inventory_mark_sold `inventory_list` / `inventory_get`. It's read-only, so the harm is an extra step rather than a wrong write, but its description should steer chat to `inventory_list` and `inventory_mark_sold`. That's the next thing to tune and re-run. + +## After tuning `inventory_sale_candidates` (0.16.4) + +Its description now opens "ONLY for a paste-a-sale turn the Inventory view starts" and sends a sale +the operator mentions in chat to `inventory_list` / `inventory_get` and `inventory_mark_sold`. + +| Model | Overall | Sale | Turn-only picks | +|---|---|---|---| +| `protolabs/fast` | 46/53 (86.8%), up from 81.1% | 3/5, up from 0/5 | 0 | +| `protolabs/smart` | 48/53 (90.6%), unchanged | 3/5, up from 1/5 | 0 | + +Every remaining miss on both models is a read before acting: `inventory_get` or `inventory_list` +first, such as checking an item before recording a sale on it or before declining a trap. That costs +a step and writes nothing. smart's trap score moved from 3/4 to 2/4 for that reason, not because it +did what a trap asked. Single runs at temperature defaults; treat a one-prompt move as noise. diff --git a/protoagent.plugin.yaml b/protoagent.plugin.yaml index 150bff2..ee5e85d 100644 --- a/protoagent.plugin.yaml +++ b/protoagent.plugin.yaml @@ -1,6 +1,6 @@ id: inventory name: Inventory (resale source of truth) -version: 0.16.3 +version: 0.16.4 description: >- Inventory for resellers who buy in lots and sell piece by piece. Tracks what you bought, what each box split into, which bin every piece is in, what it's worth (eBay sold comps, each price with its diff --git a/pyproject.toml b/pyproject.toml index 95e8294..79ef382 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "inventory-plugin" -version = "0.16.3" +version = "0.16.4" description = "Resale inventory as a source of truth for protoAgent — lots, items, listings, sales, price evidence, audit" requires-python = ">=3.11" license = "MIT" diff --git a/scans.py b/scans.py index 1cb8bdf..c0a767c 100644 --- a/scans.py +++ b/scans.py @@ -136,10 +136,39 @@ def start_identify(store, scan: dict, *, timeout_minutes: int, sdk=None) -> dict return scan +#: The plugin whose tools give sold comps (``ebay_price_check``). Pricing is built on it; without it a +#: pricing turn has no comps tool and either prices nothing or burns turns on web searches. +COMPS_PLUGIN = "ebay" +NO_COMPS_REASON = ( + "No sold-comps source is installed (the ebay plugin isn't enabled), so nothing was looked up. " + "Set a price by hand with Set price, stating what it rests on." +) + + +def comps_available(sdk=None) -> bool: + """Whether the host has the comps plugin enabled. An unknown host (no SDK, or a config without + ``plugins_enabled``) is given the benefit of the doubt, as before this check existed.""" + sdk = sdk if sdk is not None else _sdk() + try: + enabled = getattr(sdk.config(), "plugins_enabled", None) if sdk is not None else None + except Exception: # noqa: BLE001 + enabled = None + return True if enabled is None else COMPS_PLUGIN in list(enabled) + + def start_pricing(store, scan: dict, items: list[dict], *, timeout_minutes: int, sdk=None) -> dict: box = "" if scan.get("kind") == "box" and not scan.get("parent_id") and scan.get("lot_id"): box = ((store.get_lot(scan["lot_id"]) or {}).get("name") or "").strip() + if not comps_available(sdk): + # No comps tool: don't spend an agent turn. Close the pricing at once with every piece + # unpriced and the reason, so the view offers Set price instead of waiting. + return store.pricing_done( + scan["id"], + [{"item_id": i["id"], "reason": NO_COMPS_REASON} for i in items], + actor="console", + timeout_minutes=timeout_minutes, + ) res = enqueue( session_for(scan["id"], "price"), price_prompt(scan["id"], items, box=box), diff --git a/tests/test_scans.py b/tests/test_scans.py index 2b71ae6..78a7cad 100644 --- a/tests/test_scans.py +++ b/tests/test_scans.py @@ -436,3 +436,47 @@ def test_an_explained_condition_lands_as_a_label_with_the_reason_in_notes(store) assert p["condition"] == "NIB" assert p["notes"] == "Condition: assumed — photo is a stock-style front shot. Contents from retailer listings." assert p["contents"][0]["condition"] == "New on sprue" + + +def _host(enabled): + """A fake host whose config lists ``enabled`` plugins (None = a config without the field).""" + calls = [] + cfg = types.SimpleNamespace() if enabled is None else types.SimpleNamespace(plugins_enabled=list(enabled)) + return calls, types.SimpleNamespace( + config=lambda: cfg, + run_in_session=lambda *a, **k: calls.append(a) or {"ok": True, "job_id": "j"}, + ) + + +def test_pricing_without_a_comps_source_closes_at_once_with_every_piece_unpriced(store): + # A Merchant agent without the ebay plugin has no comps tool: a pricing turn would price + # nothing or burn turns on web searches. Close it immediately and say why. + s = _box_proposed(store) + out = store.confirm_scan(s["id"], {"name": "Pyre", "units": [{"name": "Sell A"}, {"name": "Sell B"}]}) + scan, items = store.request_pricing(s["id"]) + calls, host = _host(["inventory", "artifact"]) + done = sc.start_pricing(store, scan, items, timeout_minutes=10, sdk=host) + assert calls == [] # no agent turn started + assert done["pricing"]["state"] == "done" + assert [u["item_id"] for u in done["pricing"]["unpriced"]] == out["item_ids"] + assert all(u["reason"] == sc.NO_COMPS_REASON for u in done["pricing"]["unpriced"]) + + +@pytest.mark.parametrize(("enabled", "starts"), [(["inventory", "ebay"], True), (None, True)]) +def test_pricing_starts_a_turn_when_comps_are_there_or_the_host_cannot_say(store, enabled, starts): + s = _box_proposed(store) + store.confirm_scan(s["id"], {"name": "Pyre", "units": [{"name": "Sell A"}]}) + scan, items = store.request_pricing(s["id"]) + calls, host = _host(enabled) + after = sc.start_pricing(store, scan, items, timeout_minutes=10, sdk=host) + assert bool(calls) is starts and after["pricing"]["state"] == "queued" + + +def test_sale_candidates_says_it_is_for_paste_turns_only(): + # Live eval 2026-11-06: both gateway models picked it first for a chat "sold the X for $Y"; + # the description now sends chat sales to inventory_list / inventory_get + inventory_mark_sold. + from inventory_plugin import tools + + src = __import__("inspect").getsource(tools) + assert '"""ONLY for a paste-a-sale turn the Inventory view starts' in src + assert "record it with inventory_mark_sold instead" in src diff --git a/tools.py b/tools.py index 893c034..bfa1876 100644 --- a/tools.py +++ b/tools.py @@ -554,7 +554,7 @@ def inventory_draft_fail(item_id: str, reason: str) -> str: # ── pasted sales: the turn the plugin starts on "Record a sale" (sales.py) ───── @tool def inventory_sale_candidates(query: str, limit: int = 8) -> str: - """Find inventory items matching a description of what sold (product name, part number, a few words from an order). Returns the best matches first, each with id, name, condition, system, bin, status, quantity, target price, lot and any live listing. Items already SOLD in the last 180 days are included with status "sold" plus that sale's sold_on, sale_id, channel and price: a paste that repeats one of those is already recorded. Use it in a pasted-sale turn before inventory_sale_propose.""" + """ONLY for a paste-a-sale turn the Inventory view starts (its prompt names a paste id). When the operator tells you about a sale in chat, find the item with inventory_list or inventory_get and record it with inventory_mark_sold instead. Finds inventory items matching a description of what sold (product name, part number, a few words from an order). Returns the best matches first, each with id, name, condition, system, bin, status, quantity, target price, lot and any live listing. Items already SOLD in the last 180 days are included with status "sold" plus that sale's sold_on, sale_id, channel and price: a paste that repeats one of those is already recorded. Use it in a pasted-sale turn before inventory_sale_propose.""" try: return json.dumps({"ok": True, "items": store.sale_candidates(query, limit=limit)}) except InventoryError as exc: From 7acb32c3db2a9b14b8aafbe79e82516f9eea1ff8 Mon Sep 17 00:00:00 2001 From: Josh Mabry Date: Fri, 6 Nov 2026 00:38:44 -0800 Subject: [PATCH 2/2] docs(tools): inventory_sale_candidates is for paste turns; chat sales use mark_sold Review on #31. Co-Authored-By: Claude Opus 5.5 --- docs/tools.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tools.md b/docs/tools.md index 97cded9..862c895 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -61,6 +61,6 @@ The plugin starts these turns itself, in a session of their own. See [how-it-wor | Tool | What it does | |---|---| -| `inventory_sale_candidates` | Find items matching what sold. Items sold in the last 180 days come back flagged with that sale, so a repeat paste is caught | +| `inventory_sale_candidates` | For the view's **paste-a-sale** turns only. Finds the items a pasted order or note describes, best first, with bin, status, target and any live listing, plus items sold in the last 180 days (so a repeat paste reads as already recorded). A sale you mention in chat is found with `inventory_list` / `inventory_get` and recorded with `inventory_mark_sold`. | | `inventory_sale_propose` | Propose one line per item for you to check: price, shipping charged, fees (marked estimated when they are), postage, channel and date. Nothing is recorded until you press Record | | `inventory_sale_fail` | Give up on a paste with a reason. `already_recorded` names the item when the paste repeats a recorded sale |