Repository navigation
feat(sessions): GetTotalCostAsync, a session's cost with every descendant subagent session - #985
Merged
Merged
Conversation
…te the id at the call
…'s client data store
…n and failures at every level
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
What does this PR do?
It adds
Sessions.GetTotalCostAsync: a session's total cost including its subagent sessions, as opencode's own first-party client computes it. The source is the client data store'scost(),packages/client/src/solid/data.ts:1582-1590at the v2.3.2 pin.The rule:
Cost;Costplus theCostof every descendant session, the subtree upstream's store converges on as it loads them.How it reads:
ParentId, descending order and pages of 200, as upstream's family sync reads a level;Errors:
NoThrowis refused at the call, and every failure propagates.The code: the public door is a thin extension,
SessionsClientExtensions, over an internalSessionCostTotal.One recorded divergence (ADR-0031), in
docs/architecture/client-runtime.md, section Pagination: upstream's store returns 0 for a session it has not loaded; the SDK fails with the server's not-found error, because it asks the server, where an absent session is a wrong identifier. The entry names its reversal trigger.The source watch: upstream's
packages/client/src/solid/data.tsis now watched. There are three behaviours, anchored at:The entry was added through
refresh-specat the unchanged pin, sospec/receipt.jsongains its record andspec/SNAPSHOT.mdgets the tool'sDate:line.addedOperationsandremovedOperationsare empty, because there is no delta.Docs:
NoThrow);NoThrowlimits (docs/guide/errors-and-responses.md);CHANGELOG.mdunder Added.Related Issue(s):
🔄 Type of Change
🎯 Protocol & API Surface
tests/OpenCode.Sdk.Tests/Snapshots/PublicApi.verified.txtgainsSessionsClientExtensions.GetTotalCostAsync. The Extensions package is unchanged.dotnet run --file tools/opencode-tool.cs -- generate --verifypassesspec/) changed throughrefresh-specat the unchanged pin, followingspec/SNAPSHOT.md.refresh-spec --verifypasses.external/was hand-edited🧪 Testing
How has this been tested?
SessionsClientExtensionsTests, canned HTTP):NoThrowrefusal and an invalid id, both at the call;SessionsClientExtensionsLiveTests): a real subagent child, made by driving the built-insubagenttool through the simulated server. It proves the parent filter and the walk.opencode serve2.3.2 (the simulated server)Test Environment:
✅ Completion Gate
quality-gates.mdpasses on the pushed head:--help,generate --verifyandrefresh-spec --verify.📚 Documentation
docs/guide/updatedCHANGELOG.mdentry added✅ Code Quality Checklist
master