Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
13 changes: 13 additions & 0 deletions docs/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions evals/tool_selection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion protoagent.plugin.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
29 changes: 29 additions & 0 deletions scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
44 changes: 44 additions & 0 deletions tests/test_scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading