You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AI: add agent.assert_tokens() for accumulated token limits (#200)
* feat(ai): add agent.assert_tokens() for accumulated token limits
agent.assert_tokens(lambda x: x.where('input', '<=', 5000).where('output', '<=', 5000))
Tokens accumulate across every prompt()/stream() in a session (summing each
ai message's token uses from the transcript, with a usage fallback), and the
fluent TokenQuery evaluates where-clauses over input/output/cache/total. Works
on both live-record and replay; to_response() now carries the transcript so
replayed turns expose their per-message uses.
* style(ai): ruff-format assert_tokens docstring
* style(ai): ruff-format runner.py and test_record_cassette_format.py
CI runs 'ruff format --check .' repo-wide; these two files (carried in from
#199) were unformatted and failed the check.
* test(orm): fix polymorphic relation tests to use the record relationship
The Like model's MorphTo relationship is named 'record'; the tests referenced
a nonexistent 'like.log' attribute, which returned None and failed to await /
assert. Aligns with the eager-load case that already uses with_('record').
0 commit comments