fix(rpc): a playbook run started over RPC attributes its token usage to no session
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start at the playbooks.run RPC entry and trace how usage_context.bind, sessions.get_or_create, and usage_tracker determine the session owner. Review the three listed ownership options with the usage-ledger rules, then add coverage showing the chosen behavior for an existing and unknown session without unintended session creation.
Written by the indexing model from the issue text.
Description
Summary
A playbook run started over RPC has its nodes' token spend attributed to no
session. The run itself is correct -- it reports to the named conversation, and
since the execution-context fix it also works in that session's workspace and on
its model binding -- but the usage ledger does not know which session to charge.
Where it comes from
usage_tracker reads the session to charge from a context variable:
session = usage.session_key or usage_context.session_key()
That variable is established in exactly one place, the turn path:
usage_context.bind(cid, self.sessions.get_or_create(cid).metadata.get("usage_owner", {}))
An RPC entry is not a turn, so it never enters that binding. The sibling
contexts a dispatch needs -- workdir.bind for the workspace and use_binding
for the model pair -- are now entered around the dispatch by
playbooks.run; this one was left out deliberately and is recorded here rather
than forgotten.
Why it was not closed with the others
The workspace and the binding decide what work the run does: without them a
run executed in the wrong project and on the wrong model. This one decides who
is billed for it, which is an accounting gap rather than a wrong action, and
closing it needs a decision the other two did not:
usage_context.bind takes an owner read from sessions.get_or_create(cid).
Calling that from an RPC handler would have running a playbook create a session
record as a side effect, for a session_key the caller supplied and that this
layer does not otherwise require to exist. That is a policy question about what
an RPC call may bring into being, not a detail of the run.
Options
- Bind with a read-only owner lookup. Attribute to
session_keyand read
the owner only if the session already exists, passingNoneotherwise. No
session is created; a run aimed at a session that has never spoken is charged
to that key with no owner, which is strictly better than charged to nothing. - Let the RPC entry create the session record, matching the turn path
exactly. Simplest, and the one with the side effect worth agreeing to first. - Attribute at the dispatch instead of the entry, if the graph tool is a
better place for it than the caller -- worth considering because every future
non-turn entry would otherwise have to remember this.
(1) looks like the smallest correct step, but the choice belongs with whoever
owns the usage ledger's rules about unknown sessions.
Reproducing
Call playbooks.run with a session_key and a playbook whose nodes reach a
model, then look at the usage record for those nodes: session_key is empty
where a turn-initiated run of the same playbook carries the conversation.
- Dominant language
- Python
- Stars
- 4.1k
- Forks
- 94
- Avg merge
- 15h 38m
- Merged PRs (30d)
- 400
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from EverMind-AI/Raven
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
EverMind-AI/Raven#1000 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
EverMind-AI/Raven#998 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
EverMind-AI/Raven#997 ·
Maintainers usually reply within 1 day
-
fix: two error hints tell users to install raven by name, which is Sentry's client on PyPIPossibly taken @TheIrvin claimed this 17 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EverMind-AI/Raven#845 · 2 comments ·
Maintainers usually reply within 1 day
-
security: tool output scrubbing misses raven's own oauth token filesPossibly taken @akushonkamen claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
EverMind-AI/Raven#842 · 2 comments ·
Maintainers usually reply within 1 day
All issues in EverMind-AI/Raven
Similar issues
-
idxmax/idxmin raise ValueError when a single partition is all-NAPossibly taken @Jason10191019999 claimed this today. Openneeds triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 3 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
[BUG]: Windows GUI package of v1.17.0-rc3 has no GTK DLLsPossibly taken @andrut-ds claimed this today. Openbug CI/CD Pactus-GUI Windows
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
pactus-project/pactus#2428 ·
Maintainers usually reply within 1 day
-
DiskDataset.reshard() can hang with a zero or negative shard sizePossibly taken @Programmer-Develops claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 19 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
GNS3/gns3-server#3017 · 1 comment ·
Maintainers usually reply within 1 day