feat(event): add canonical Usage event builder, adapter contract, and dep bump#3
Open
chgeuer wants to merge 3 commits intoagentjido:mainfrom
Open
feat(event): add canonical Usage event builder, adapter contract, and dep bump#3chgeuer wants to merge 3 commits intoagentjido:mainfrom
chgeuer wants to merge 3 commits intoagentjido:mainfrom
Conversation
The module was renamed in jido_shell PR #22 (commit b5132be) from Jido.Shell.SpriteLifecycle to Jido.Shell.Environment.Sprite. Closes agentjido#2
Add Jido.Harness.Event.Usage.build/3 that produces a standardized :usage event with flat payload (input_tokens, output_tokens, total_tokens, plus optional cached_input_tokens, cost_usd, duration_ms, model). Extend AdapterContract: adapters declaring usage?: true must emit at least one :usage event with the required payload keys and a non-nil session_id.
This was referenced Mar 22, 2026
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.
Closes #4
What
Adds
Jido.Harness.Event.Usage.build/3— a builder that constructs canonical:usageevents with a standardized flat payload. Also extends AdapterContract to verify that adapters declaringusage?: trueemit at least one conforming:usageevent.Canonical payload shape
Key design decisions:
"usage"key) — simpler for consumers to pattern-match:session_completedsession_idrequired — enables session-level aggregationUsage
Changes
lib/jido_harness/event/usage.ex— new module withbuild/3and@moduledocdocumenting the contractlib/jido_harness/adapter_contract.ex— new contract test: adapters withusage?: truemust emit:usageevents withinput_tokens,output_tokens,total_tokens, and a non-nilsession_idtest/jido_harness/event/usage_test.exs— 8 unit tests covering required/optional fields, defaults, and validationmix.exs— bumps jido dep to~> 2.1Test results
67 tests, 0 failures