Skip to content

microskills: the proposer's call costs nothing in the ledger when its CLI reports no usage #312

Open

Description

Every paid side call the plugin makes is charged to the ledger as overhead. The loop guard's judge and redirect writer charge the usage their runner recovered, or else an estimate on the same basis (pricing.runner_effective_or_approx: the prompt at 1x, the reply at 5x).

The micro-skills proposer in tokeneconomizer/microskills/distiller.py charges only recovered usage:

if eff is not None:
    self.opt_tokens += eff

So a proposer call whose CLI reports no usage adds nothing to opt_tokens, and the ledger's overhead and overhead share leave it out. Cursor's side calls never report usage (cursor_call returns None); the other CLIs don't when their usage block is missing. On Cursor, the judge's calls are charged an estimate while the proposer's are free.

Reproduction (offline):

import json, os, tempfile
from tokeneconomizer.microskills import GENERIC
from tokeneconomizer.microskills import distiller as dist

reply = '{"extractors": [], "facts": []}'
def runner(prompt, model):          # a side call whose CLI reports no usage
    return reply, None

dist.PROPOSE_EVERY = 1
tmp = tempfile.mkdtemp()
d = dist.Distiller.load("acme/tool", tmp, runner=runner, vocab=GENERIC)
path = os.path.join(tmp, "s.jsonl")
lines = [{"type": "assistant", "message": {"id": "m1", "content": [
             {"type": "tool_use", "id": "t1", "name": "Bash", "input": {"command": "make test"}}]}},
         {"type": "user", "message": {"content": [
             {"type": "tool_result", "tool_use_id": "t1", "content": "ok"}]}}]
open(path, "w").write("\n".join(json.dumps(x) for x in lines) + "\n")
d.update(path, iid="s0")
print("proposer charged:", d.opt_tokens)

Expected: an estimate, as the judge charges for a call with no usage
Actual: proposer charged: 0.0

Upstream main: 1bfeccd
Python 3.13.18, Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions