agentenv-framework-protocol 0.1.593__tar.gz → 0.1.597__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/PKG-INFO +46 -2
  2. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/README.md +45 -1
  3. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/pyproject.toml +1 -1
  4. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/__init__.py +2 -0
  5. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/extensions.py +7 -0
  6. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/proxy.py +73 -8
  7. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/tasks/v1.py +97 -25
  8. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_proxy.py +148 -1
  9. agentenv_framework_protocol-0.1.597/tests/test_usage.py +140 -0
  10. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/.gitignore +0 -0
  11. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/LICENSE +0 -0
  12. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/NOTICE +0 -0
  13. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/THIRD_PARTY_NOTICES.md +0 -0
  14. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/__init__.py +0 -0
  15. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/advanced_agent.py +0 -0
  16. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/basic_agent.py +0 -0
  17. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/custom_extensions_agent.py +0 -0
  18. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/multimodal_agent.py +0 -0
  19. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/reference_model.py +0 -0
  20. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/streaming_agent.py +0 -0
  21. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/.gitignore +0 -0
  22. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/Dockerfile +0 -0
  23. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/Dockerfile.dockerignore +0 -0
  24. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/README.md +0 -0
  25. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/data/seed.json +0 -0
  26. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/env.toml +0 -0
  27. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/site.py +0 -0
  28. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/web/index.html +0 -0
  29. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/web/package-lock.json +0 -0
  30. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/web/package.json +0 -0
  31. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/web/src/main.js +0 -0
  32. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/web/src/style.css +0 -0
  33. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/examples/website/notes/web/vite.config.js +0 -0
  34. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/__init__.py +0 -0
  35. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/_trajectory_log.py +0 -0
  36. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/_triggers.py +0 -0
  37. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/clock.py +0 -0
  38. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/control_token.py +0 -0
  39. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/framework.py +0 -0
  40. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/peer_agents.py +0 -0
  41. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/registry.py +0 -0
  42. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/staging.py +0 -0
  43. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/a2a_agent/tasks/__init__.py +0 -0
  44. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/agent_env_environment.py +0 -0
  45. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/PROFILE.md +0 -0
  46. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/__init__.py +0 -0
  47. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/__main__.py +0 -0
  48. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/adapter.py +0 -0
  49. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/builder.py +0 -0
  50. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/coding.json +0 -0
  51. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/coding.stripped.json +0 -0
  52. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/computer_use.json +0 -0
  53. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/late_result.json +0 -0
  54. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/media/482405b002a62efa8516c36709a7a100637507670576fa73a20ad5420d55c66f.png +0 -0
  55. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/media/55c64d0fcd6f9d5f7c828093857e3fdfda68478bb4e9bd24d481ef391c7804e8.heic +0 -0
  56. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/media/67905ad3cc2dd52b1f5f6a6d2814de0396618b29b4238b9af5207aeb69936e6d.mp4 +0 -0
  57. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/media/69a8aa01fe5537076d023dd5e9cc4275b39fc0434aa6483a9f58b66ef2f3c896.png +0 -0
  58. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/media/82e60066a2de261b6653bcdda90d1cb9a7af2f474cecd82e8d371e8384d72315.png +0 -0
  59. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/media/845e91831319e89c4d656bdb80c278ac09a7230d61e5dfd2e1b1fbb436ac8917.pdf +0 -0
  60. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/multi_agent.json +0 -0
  61. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/odd_parts.json +0 -0
  62. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/subagent.json +0 -0
  63. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/fixtures/two_turns.json +0 -0
  64. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/kit.py +0 -0
  65. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/LICENSE +0 -0
  66. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/VENDORED.md +0 -0
  67. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/__init__.py +0 -0
  68. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/agent.py +0 -0
  69. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/content.py +0 -0
  70. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/final_metrics.py +0 -0
  71. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/metrics.py +0 -0
  72. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/observation.py +0 -0
  73. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/observation_result.py +0 -0
  74. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/step.py +0 -0
  75. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/subagent_trajectory_ref.py +0 -0
  76. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/tool_call.py +0 -0
  77. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/models/trajectory.py +0 -0
  78. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/profile.py +0 -0
  79. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/reader.py +0 -0
  80. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/runner.py +0 -0
  81. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/atif/validator.py +0 -0
  82. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/client.py +0 -0
  83. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/__init__.py +0 -0
  84. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_declare.py +0 -0
  85. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_desktop.py +0 -0
  86. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_job.py +0 -0
  87. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_linux.py +0 -0
  88. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_load.py +0 -0
  89. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_macos.py +0 -0
  90. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_reaping.py +0 -0
  91. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_session_posix.py +0 -0
  92. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_session_windows.py +0 -0
  93. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_windows.py +0 -0
  94. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_with_fds.py +0 -0
  95. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/_x11.py +0 -0
  96. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/app.py +0 -0
  97. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/app_data.py +0 -0
  98. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/app_runtime.py +0 -0
  99. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/apps.py +0 -0
  100. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/card.py +0 -0
  101. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/checks.py +0 -0
  102. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/clock.py +0 -0
  103. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/__init__.py +0 -0
  104. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/__main__.py +0 -0
  105. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/checks.py +0 -0
  106. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/client.py +0 -0
  107. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/desk.py +0 -0
  108. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/fixture.py +0 -0
  109. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/mp4.py +0 -0
  110. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/page_fixture.py +0 -0
  111. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/report.py +0 -0
  112. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/conformance/wayland_fixture.py +0 -0
  113. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/dataplane.py +0 -0
  114. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/driver.py +0 -0
  115. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/errors.py +0 -0
  116. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/extensions.py +0 -0
  117. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/frames.py +0 -0
  118. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/keys.py +0 -0
  119. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/launch.py +0 -0
  120. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/manifest.py +0 -0
  121. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/operations.py +0 -0
  122. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/platform.py +0 -0
  123. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/prefix.py +0 -0
  124. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/queue.py +0 -0
  125. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/recording.py +0 -0
  126. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/results.py +0 -0
  127. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/run_install_step.py +0 -0
  128. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/runtime.py +0 -0
  129. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/seed.py +0 -0
  130. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/serve.py +0 -0
  131. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/serve_app.py +0 -0
  132. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/served.py +0 -0
  133. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/session.py +0 -0
  134. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/settings.py +0 -0
  135. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/skill.py +0 -0
  136. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/spaces.py +0 -0
  137. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/svc.py +0 -0
  138. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/computer/tools.py +0 -0
  139. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/errors.py +0 -0
  140. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/manifest.py +0 -0
  141. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/passthrough.py +0 -0
  142. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/preflight.py +0 -0
  143. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/tool_access.py +0 -0
  144. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/tool_client.py +0 -0
  145. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/tool_context.py +0 -0
  146. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/transfers.py +0 -0
  147. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/types.py +0 -0
  148. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/__init__.py +0 -0
  149. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/clock.py +0 -0
  150. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/conformance.py +0 -0
  151. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/environment.py +0 -0
  152. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/errors.py +0 -0
  153. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/forwarding.py +0 -0
  154. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/readiness.py +0 -0
  155. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/routes.py +0 -0
  156. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website/session.py +0 -0
  157. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/__init__.py +0 -0
  158. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/cdp.py +0 -0
  159. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/contexts.py +0 -0
  160. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/control.py +0 -0
  161. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/data.py +0 -0
  162. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/devtools.py +0 -0
  163. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/environment.py +0 -0
  164. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/log.py +0 -0
  165. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/network.py +0 -0
  166. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/recording.py +0 -0
  167. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/scope.py +0 -0
  168. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/shapes.py +0 -0
  169. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/src/agentenv_protocol/website_browser/stream.py +0 -0
  170. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/atif_cases.py +0 -0
  171. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/computer_fake.py +0 -0
  172. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/probe_fake.py +0 -0
  173. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_agent.py +0 -0
  174. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_agent_clock.py +0 -0
  175. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_agent_examples.py +0 -0
  176. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_cdp_config.py +0 -0
  177. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_object_transfers.py +0 -0
  178. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_peer_agents.py +0 -0
  179. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_staging.py +0 -0
  180. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_a2a_trajectory_log.py +0 -0
  181. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_agent_env_environment.py +0 -0
  182. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_atif_builder.py +0 -0
  183. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_atif_fixtures.py +0 -0
  184. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_atif_kit.py +0 -0
  185. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_atif_profile.py +0 -0
  186. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_atif_reader.py +0 -0
  187. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_atif_validator.py +0 -0
  188. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_atif_vendored.py +0 -0
  189. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_browser_cdp.py +0 -0
  190. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_browser_contexts.py +0 -0
  191. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_browser_data.py +0 -0
  192. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_browser_log.py +0 -0
  193. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_browser_network.py +0 -0
  194. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_browser_recording.py +0 -0
  195. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_browser_state.py +0 -0
  196. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_client.py +0 -0
  197. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_app_data.py +0 -0
  198. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_app_server.py +0 -0
  199. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_clock.py +0 -0
  200. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_conformance.py +0 -0
  201. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_conformance_attempts.py +0 -0
  202. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_conformance_checks.py +0 -0
  203. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_conformance_page.py +0 -0
  204. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_conformance_recording.py +0 -0
  205. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_dataplane.py +0 -0
  206. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_declare.py +0 -0
  207. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_driver.py +0 -0
  208. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_driver_keys.py +0 -0
  209. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_extensions.py +0 -0
  210. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_frames.py +0 -0
  211. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_macos.py +0 -0
  212. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_page.py +0 -0
  213. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_queue.py +0 -0
  214. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_recording.py +0 -0
  215. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_seed.py +0 -0
  216. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_serve.py +0 -0
  217. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_served.py +0 -0
  218. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_session_windows.py +0 -0
  219. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_spaces.py +0 -0
  220. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_svc_forward.py +0 -0
  221. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_tool_prefix.py +0 -0
  222. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_computer_windows_driver.py +0 -0
  223. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_control_token.py +0 -0
  224. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_data_objects.py +0 -0
  225. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_devtools_pipe.py +0 -0
  226. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_errors.py +0 -0
  227. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_extension_methods.py +0 -0
  228. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_intake.py +0 -0
  229. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_manifest.py +0 -0
  230. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_preflight.py +0 -0
  231. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_tool_access.py +0 -0
  232. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_tool_annotations.py +0 -0
  233. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_tool_client.py +0 -0
  234. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_tool_context.py +0 -0
  235. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_tool_context_fastmcp.py +0 -0
  236. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_tool_context_injection.py +0 -0
  237. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_api.py +0 -0
  238. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_browser.py +0 -0
  239. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_conformance.py +0 -0
  240. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_environment.py +0 -0
  241. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_forwarding.py +0 -0
  242. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_live.py +0 -0
  243. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_mcp.py +0 -0
  244. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_notes_example.py +0 -0
  245. {agentenv_framework_protocol-0.1.593 → agentenv_framework_protocol-0.1.597}/tests/test_website_readiness.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agentenv-framework-protocol
3
- Version: 0.1.593
3
+ Version: 0.1.597
4
4
  Summary: Open data-plane protocol and server SDK for agent environments.
5
5
  Project-URL: Homepage, https://www.agentenvframework.com
6
6
  Project-URL: Documentation, https://www.agentenvframework.com/docs
@@ -1459,6 +1459,39 @@ Extensions come from explicit definitions, configured activations, and
1459
1459
  decorated handlers in one validated registry, so routes and card advertisement
1460
1460
  cannot drift.
1461
1461
 
1462
+ `Usage` reports what a task used: `tool_call_count`, `input_tokens`,
1463
+ `output_tokens`, `total_tokens`, `cost_usd`, the prompt-cache counts
1464
+ `cache_read_tokens` and `cache_write_tokens`, and `input_includes_cache`, which
1465
+ says whether `input_tokens` counts both cache counts (`True`), neither
1466
+ (`False`), or is unknown (`None`, the default). Set the flag whenever you set
1467
+ the cache counts: a price can't read them without it. Runtime-specific counts go
1468
+ in `provider_details`, but cache counts go in their own fields. `Usage.from_dict`
1469
+ reads what `to_dict` wrote under any protocol version, a field it leaves out
1470
+ being `None` and a key it doesn't know ignored, and `TaskResult.failure(...,
1471
+ usage=...)` carries usage on a failure as `success` does.
1472
+
1473
+ Whoever makes a model call knows what its counts hold, so an agent builds its own
1474
+ `Usage`. `Usage.from_model_response(usage)` is the default reader for a model
1475
+ response's own usage, with `input_tokens` counting the cache
1476
+ (`input_includes_cache` true), for OpenAI's Chat Completions (`prompt_tokens`)
1477
+ and Responses (`input_tokens`) shapes and Anthropic's:
1478
+
1479
+ - An OpenAI count, or a LiteLLM client's, counts the cache its
1480
+ `prompt_tokens_details` or `input_tokens_details` names: `cached_tokens`, and
1481
+ `cache_write_tokens` beside it.
1482
+ - Anthropic's `input_tokens` counts neither `cache_read_input_tokens` nor
1483
+ `cache_creation_input_tokens`, and neither does the `prompt_tokens` a LiteLLM
1484
+ proxy sends with those two beside it, so they're added, to `total_tokens` too.
1485
+ - A provider's split of its cache writes by how long they're kept, priced apart
1486
+ (Anthropic's `cache_creation`, OpenAI's `cache_write_tokens_details`), is kept
1487
+ in `provider_details`, and so are the keys of a usage in none of these shapes,
1488
+ as `unrecognized`. A value that isn't a count is left out.
1489
+
1490
+ Through a gateway, whether a response's input counts the cache depends on the
1491
+ model behind it: a LiteLLM proxy's Claude answers through Chat Completions leave
1492
+ it out, its GPT answers don't. Set `input_includes_cache` per call, never once
1493
+ per agent.
1494
+
1462
1495
  `run(request)` is the required execution contract. It is an ordinary method
1463
1496
  and needs no decorator.
1464
1497
 
@@ -1937,7 +1970,18 @@ operations:
1937
1970
  records a call, each action must be one the last recorded call made, by name and
1938
1971
  arguments (a `bash` call by its command alone, a whole float equal to its int), and all of
1939
1972
  them must run before the next `record` or the `reply`, else 409.
1940
- Calls to tools the turn doesn't offer aren't checked.
1973
+ Calls to tools the turn doesn't offer aren't checked. `usage` is the call's: a `Usage` the
1974
+ driver reports under `REPORTED_USAGE_KEY` (`{"agentenv_usage": usage.to_dict()}`), taken as
1975
+ given, or else the model response's own, read by `Usage.from_model_response`. It rides in
1976
+ `usage` rather than a field of its own, so a proxy on an earlier protocol still takes the
1977
+ record. A reported `Usage` that isn't one gets 400 and leaves the turn as it was. The call's
1978
+ input is made to count the cache, its `chat` span shows that reading, and its turn sums it.
1979
+ The turn's `Usage`, on its reply or its error, sums each count over the calls that gave it,
1980
+ `cost_usd` included. Its `provider_details` give `model_calls`, how many were recorded;
1981
+ `unreported`, how many left out each count only some gave, so such a sum reads as a lower
1982
+ bound; `cache_unsettled`, how many had cache counts with no word on whether their input held
1983
+ them, which leaves the turn's flag unknown; `unrecognized`, how many usages were in no shape
1984
+ the reader knows; and each provider's cache-write split, summed.
1941
1985
  - `reply` (`{"token", "task_id", "parts"}`, or `"error"` in place of `"parts"`) ends the
1942
1986
  turn: parts complete the task, and an error fails it as `proxy.driver_error`.
1943
1987
 
@@ -1388,6 +1388,39 @@ Extensions come from explicit definitions, configured activations, and
1388
1388
  decorated handlers in one validated registry, so routes and card advertisement
1389
1389
  cannot drift.
1390
1390
 
1391
+ `Usage` reports what a task used: `tool_call_count`, `input_tokens`,
1392
+ `output_tokens`, `total_tokens`, `cost_usd`, the prompt-cache counts
1393
+ `cache_read_tokens` and `cache_write_tokens`, and `input_includes_cache`, which
1394
+ says whether `input_tokens` counts both cache counts (`True`), neither
1395
+ (`False`), or is unknown (`None`, the default). Set the flag whenever you set
1396
+ the cache counts: a price can't read them without it. Runtime-specific counts go
1397
+ in `provider_details`, but cache counts go in their own fields. `Usage.from_dict`
1398
+ reads what `to_dict` wrote under any protocol version, a field it leaves out
1399
+ being `None` and a key it doesn't know ignored, and `TaskResult.failure(...,
1400
+ usage=...)` carries usage on a failure as `success` does.
1401
+
1402
+ Whoever makes a model call knows what its counts hold, so an agent builds its own
1403
+ `Usage`. `Usage.from_model_response(usage)` is the default reader for a model
1404
+ response's own usage, with `input_tokens` counting the cache
1405
+ (`input_includes_cache` true), for OpenAI's Chat Completions (`prompt_tokens`)
1406
+ and Responses (`input_tokens`) shapes and Anthropic's:
1407
+
1408
+ - An OpenAI count, or a LiteLLM client's, counts the cache its
1409
+ `prompt_tokens_details` or `input_tokens_details` names: `cached_tokens`, and
1410
+ `cache_write_tokens` beside it.
1411
+ - Anthropic's `input_tokens` counts neither `cache_read_input_tokens` nor
1412
+ `cache_creation_input_tokens`, and neither does the `prompt_tokens` a LiteLLM
1413
+ proxy sends with those two beside it, so they're added, to `total_tokens` too.
1414
+ - A provider's split of its cache writes by how long they're kept, priced apart
1415
+ (Anthropic's `cache_creation`, OpenAI's `cache_write_tokens_details`), is kept
1416
+ in `provider_details`, and so are the keys of a usage in none of these shapes,
1417
+ as `unrecognized`. A value that isn't a count is left out.
1418
+
1419
+ Through a gateway, whether a response's input counts the cache depends on the
1420
+ model behind it: a LiteLLM proxy's Claude answers through Chat Completions leave
1421
+ it out, its GPT answers don't. Set `input_includes_cache` per call, never once
1422
+ per agent.
1423
+
1391
1424
  `run(request)` is the required execution contract. It is an ordinary method
1392
1425
  and needs no decorator.
1393
1426
 
@@ -1866,7 +1899,18 @@ operations:
1866
1899
  records a call, each action must be one the last recorded call made, by name and
1867
1900
  arguments (a `bash` call by its command alone, a whole float equal to its int), and all of
1868
1901
  them must run before the next `record` or the `reply`, else 409.
1869
- Calls to tools the turn doesn't offer aren't checked.
1902
+ Calls to tools the turn doesn't offer aren't checked. `usage` is the call's: a `Usage` the
1903
+ driver reports under `REPORTED_USAGE_KEY` (`{"agentenv_usage": usage.to_dict()}`), taken as
1904
+ given, or else the model response's own, read by `Usage.from_model_response`. It rides in
1905
+ `usage` rather than a field of its own, so a proxy on an earlier protocol still takes the
1906
+ record. A reported `Usage` that isn't one gets 400 and leaves the turn as it was. The call's
1907
+ input is made to count the cache, its `chat` span shows that reading, and its turn sums it.
1908
+ The turn's `Usage`, on its reply or its error, sums each count over the calls that gave it,
1909
+ `cost_usd` included. Its `provider_details` give `model_calls`, how many were recorded;
1910
+ `unreported`, how many left out each count only some gave, so such a sum reads as a lower
1911
+ bound; `cache_unsettled`, how many had cache counts with no word on whether their input held
1912
+ them, which leaves the turn's flag unknown; `unrecognized`, how many usages were in no shape
1913
+ the reader knows; and each provider's cache-write split, summed.
1870
1914
  - `reply` (`{"token", "task_id", "parts"}`, or `"error"` in place of `"parts"`) ends the
1871
1915
  turn: parts complete the task, and an error fails it as `proxy.driver_error`.
1872
1916
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentenv-framework-protocol"
3
- version = "0.1.593"
3
+ version = "0.1.597"
4
4
  description = "Open data-plane protocol and server SDK for agent environments."
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
@@ -10,6 +10,7 @@ from .extensions import (
10
10
  INSTALL_V1,
11
11
  MCP_CONFIG_V1,
12
12
  PEER_AGENTS_V1,
13
+ REPORTED_USAGE_KEY,
13
14
  SKILL_CONFIG_V1,
14
15
  SNAPSHOT_V1,
15
16
  STANDARD_EXTENSIONS,
@@ -147,6 +148,7 @@ __all__ = [
147
148
  "INSTALL_V1",
148
149
  "MCP_CONFIG_V1",
149
150
  "PEER_AGENTS_V1",
151
+ "REPORTED_USAGE_KEY",
150
152
  "SKILL_CONFIG_V1",
151
153
  "SNAPSHOT_V1",
152
154
  "STAGING_ENDPOINT",
@@ -450,6 +450,13 @@ class ProxyActionState(ExtensionResponse):
450
450
  result: Annotated[ProxyBashResult | ProxyToolResult, Field(discriminator="kind")] | None = None
451
451
 
452
452
 
453
+ # The key under which a record's ``usage`` carries a ``Usage`` its driver reported, as ``Usage.to_dict`` wrote it; any
454
+ # other ``usage`` is a model response's own, which the proxy reads with ``Usage.from_model_response``. It rides in
455
+ # ``usage`` rather than a field of its own so a proxy on an earlier protocol, whose request refuses unknown fields,
456
+ # still takes the record.
457
+ REPORTED_USAGE_KEY = "agentenv_usage"
458
+
459
+
453
460
  class ProxyRecordRequest(ExtensionRequest):
454
461
  token: str
455
462
  task_id: str
@@ -18,8 +18,8 @@ import os
18
18
  import shutil
19
19
  import signal
20
20
  from collections import defaultdict
21
- from collections.abc import AsyncIterator
22
- from dataclasses import dataclass, field
21
+ from collections.abc import AsyncIterator, Mapping
22
+ from dataclasses import dataclass, field, fields, replace
23
23
  from datetime import datetime, timezone
24
24
  from pathlib import Path
25
25
  from typing import Any
@@ -31,6 +31,7 @@ from starlette.exceptions import HTTPException
31
31
  from .extensions import (
32
32
  MCP_CONFIG_V1,
33
33
  PROXY_V1,
34
+ REPORTED_USAGE_KEY,
34
35
  SKILL_CONFIG_V1,
35
36
  TRAJECTORY_V1,
36
37
  BundleSkillRequest,
@@ -111,6 +112,7 @@ class _Turn:
111
112
  pending: list[tuple[str, str]] = field(default_factory=list) # (tool, its canonical arguments) not yet run
112
113
  last_event: str = field(default_factory=lambda: _now())
113
114
  model: str | None = None
115
+ model_usage: list[Usage] = field(default_factory=list) # each recorded model call's, its input counting the cache
114
116
 
115
117
 
116
118
  @contextlib.asynccontextmanager
@@ -174,11 +176,11 @@ class ProxyAgent(AgentEnvAgent):
174
176
  if reply.error is not None:
175
177
  turn.trajectory.append(_span("turn", "chain", turn.started, turn.model, prompt=prompt,
176
178
  completion={"error": reply.error}, failed=True))
177
- return TaskResult.failure("proxy.driver_error", reply.error)
179
+ return TaskResult.failure("proxy.driver_error", reply.error, usage=_turn_usage(turn))
178
180
  turn.trajectory.append(_span("turn", "chain", turn.started, turn.model, prompt=prompt, completion={
179
181
  "content": [{"type": "text", "text": part.text} for part in reply.parts]}))
180
182
  return TaskResult.success(parts=tuple(TextPart(text=part.text) for part in reply.parts),
181
- usage=Usage(tool_call_count=len(turn.actions)))
183
+ usage=_turn_usage(turn))
182
184
 
183
185
  @extension(PROXY_V1.claim)
184
186
  async def claim(self, request: ProxyClaimRequest) -> None:
@@ -238,6 +240,7 @@ class ProxyAgent(AgentEnvAgent):
238
240
  @extension(PROXY_V1.record)
239
241
  async def record(self, request: ProxyRecordRequest) -> None:
240
242
  content, calls = _read_message(request.message)
243
+ usage = _counting_cache(_recorded_usage(request.usage))
241
244
  offered = await self._tools(self._open_turn(request.token, request.task_id))
242
245
  turn = self._open_turn(request.token, request.task_id)
243
246
  if turn.pending:
@@ -247,10 +250,9 @@ class ProxyAgent(AgentEnvAgent):
247
250
  turn.recorded = True
248
251
  turn.model = request.model or turn.model
249
252
  span = _span("chat", "chat", turn.last_event, turn.model, completion={"content": content})
250
- usage = request.usage or {}
251
- for key, names in (("input_tokens", ("input_tokens", "prompt_tokens")),
252
- ("output_tokens", ("output_tokens", "completion_tokens"))):
253
- if (count := next((usage[name] for name in names if name in usage), None)) is not None:
253
+ turn.model_usage.append(usage)
254
+ for key in ("input_tokens", "output_tokens"):
255
+ if (count := getattr(usage, key)) is not None:
254
256
  span["attributes"][f"gen_ai.usage.{key}"] = count
255
257
  turn.trajectory.append(span)
256
258
  turn.last_event = span["end_time"]
@@ -519,6 +521,69 @@ def _tool_error(message: str) -> ProxyToolResult:
519
521
  return ProxyToolResult(content=[{"type": "text", "text": f"error: {message}"}], is_error=True)
520
522
 
521
523
 
524
+ _USAGE_SUMS = (*(f.name for f in fields(Usage) if f.name.endswith("_tokens")), "cost_usd")
525
+ # Each provider's split of its cache writes by how long they're kept, which ``Usage.from_model_response`` keeps.
526
+ _CACHE_WRITE_SPLITS = ("cache_creation", "cache_write_tokens_details")
527
+
528
+
529
+ def _recorded_usage(usage: dict[str, Any] | None) -> Usage:
530
+ """A recorded call's usage: the ``Usage`` its driver reported under ``REPORTED_USAGE_KEY``, taken as given, or
531
+ else read from the model response's own by ``Usage.from_model_response``."""
532
+ if usage is None:
533
+ return Usage()
534
+ if REPORTED_USAGE_KEY not in usage:
535
+ return Usage.from_model_response(usage)
536
+ try:
537
+ return Usage.from_dict(usage[REPORTED_USAGE_KEY])
538
+ except (TypeError, ValueError) as e:
539
+ raise HTTPException(status_code=400, detail=f"usage[{REPORTED_USAGE_KEY!r}]: {e}") from e
540
+
541
+
542
+ def _counting_cache(usage: Usage) -> Usage:
543
+ """``usage`` with its ``input_tokens`` counting the cache, as its span shows it and its turn sums it: one that
544
+ leaves the cache out has it added, to its total too, and one with no cache to count counts it. One whose flag is
545
+ unknown while it has cache counts stays as given."""
546
+ cache = (usage.cache_read_tokens or 0) + (usage.cache_write_tokens or 0)
547
+ if usage.input_tokens is None or usage.input_includes_cache is True:
548
+ return usage
549
+ if usage.input_includes_cache is False:
550
+ total = None if usage.total_tokens is None else usage.total_tokens + cache
551
+ return replace(usage, input_tokens=usage.input_tokens + cache, total_tokens=total, input_includes_cache=True)
552
+ return replace(usage, input_includes_cache=True) if cache == 0 else usage
553
+
554
+
555
+ def _turn_usage(turn: _Turn) -> Usage:
556
+ """The turn's usage: the calls to its tools, and each count summed over the recorded model calls that gave it,
557
+ None when none did, with ``input_tokens`` counting the cache. ``provider_details`` says how many calls were
558
+ recorded (``model_calls``); for a count only some gave, how many left it out (``unreported``), so the sum reads
559
+ as the lower bound it is; how many had cache counts with no word on whether their input held them
560
+ (``cache_unsettled``), which leaves the turn's flag unknown; how many usages were in a shape none of the readers
561
+ know (``unrecognized``); and each provider's split of the cache writes, summed, a reported ``Usage``'s split
562
+ counted only where it holds counts, as its ``provider_details`` may hold anything."""
563
+ calls = turn.model_usage
564
+ sums, unreported = {}, {}
565
+ for name in _USAGE_SUMS:
566
+ values = [value for call in calls if (value := getattr(call, name)) is not None]
567
+ sums[name] = sum(values) if values else None
568
+ if values and len(values) < len(calls):
569
+ unreported[name] = len(calls) - len(values)
570
+ unsettled = sum(call.input_tokens is not None and call.input_includes_cache is None for call in calls)
571
+ unrecognized = sum("unrecognized" in call.provider_details for call in calls)
572
+ splits: dict[str, dict[str, int]] = {}
573
+ for call in calls:
574
+ for name in _CACHE_WRITE_SPLITS:
575
+ if isinstance(split := call.provider_details.get(name), Mapping):
576
+ for part, count in split.items():
577
+ if isinstance(count, int) and not isinstance(count, bool) and count >= 0:
578
+ splits.setdefault(name, {})[part] = splits.get(name, {}).get(part, 0) + count
579
+ details = {"model_calls": len(calls), **({"unreported": unreported} if unreported else {}),
580
+ **({"cache_unsettled": unsettled} if unsettled else {}),
581
+ **({"unrecognized": unrecognized} if unrecognized else {}), **splits}
582
+ return Usage(tool_call_count=len(turn.actions), **sums,
583
+ input_includes_cache=True if sums["input_tokens"] is not None and not unsettled else None,
584
+ provider_details=details if calls else {})
585
+
586
+
522
587
  def _span(name: str, operation: str, started: str, model: str | None, *, prompt: Any = None,
523
588
  completion: Any = None, failed: bool = False) -> dict[str, Any]:
524
589
  """An OTel GenAI span, the trajectory format rubrics and the explorer read."""
@@ -11,7 +11,7 @@ from __future__ import annotations
11
11
  import json
12
12
  import logging
13
13
  from collections.abc import AsyncIterator, Awaitable, Iterable, Mapping
14
- from dataclasses import dataclass, field
14
+ from dataclasses import dataclass, field, fields
15
15
  from enum import Enum
16
16
  from pathlib import Path
17
17
  from typing import Annotated, Any, Generic, Literal, TypeAlias, TypeVar, Union
@@ -315,29 +315,55 @@ class NativeTrajectory:
315
315
  object.__setattr__(self, "payload", _copy_json_value(self.payload))
316
316
 
317
317
 
318
+ _USAGE_COUNTERS = (
319
+ "tool_call_count",
320
+ "input_tokens",
321
+ "output_tokens",
322
+ "total_tokens",
323
+ "cache_read_tokens",
324
+ "cache_write_tokens",
325
+ )
326
+
327
+
328
+ # The keys a model response's usage is read by, in any of the shapes ``Usage.from_model_response`` reads.
329
+ _RESPONSE_USAGE_KEYS = frozenset({
330
+ "prompt_tokens", "completion_tokens", "input_tokens", "output_tokens", "total_tokens",
331
+ "prompt_tokens_details", "input_tokens_details", "cache_read_input_tokens", "cache_creation_input_tokens",
332
+ })
333
+
334
+
335
+ def _count(value: Any) -> int | None:
336
+ return value if isinstance(value, int) and not isinstance(value, bool) and value >= 0 else None
337
+
338
+
318
339
  @dataclass(frozen=True, slots=True, kw_only=True)
319
340
  class Usage:
320
- """Common execution metrics plus runtime-specific, JSON-shaped details."""
341
+ """Common execution metrics plus runtime-specific, JSON-shaped details. ``cache_read_tokens`` and
342
+ ``cache_write_tokens`` count the prompt tokens read from and written to the provider's prompt cache;
343
+ ``input_includes_cache`` says whether ``input_tokens`` counts both of them (True), neither (False), or is unknown
344
+ (None), which a price needs to read the counts."""
321
345
 
322
346
  tool_call_count: int | None = None
323
347
  input_tokens: int | None = None
324
348
  output_tokens: int | None = None
325
349
  total_tokens: int | None = None
350
+ cache_read_tokens: int | None = None
351
+ cache_write_tokens: int | None = None
352
+ input_includes_cache: bool | None = None
326
353
  cost_usd: float | None = None
327
354
  provider_details: Mapping[str, Any] = field(default_factory=dict)
328
355
 
329
356
  def __post_init__(self) -> None:
330
- for name in (
331
- "tool_call_count",
332
- "input_tokens",
333
- "output_tokens",
334
- "total_tokens",
335
- ):
357
+ for name in _USAGE_COUNTERS:
336
358
  value = getattr(self, name)
337
359
  if value is not None and (
338
360
  isinstance(value, bool) or not isinstance(value, int) or value < 0
339
361
  ):
340
- raise ValueError(f"{name} cannot be negative")
362
+ raise ValueError(f"{name} must be a non-negative integer")
363
+ if self.input_includes_cache is not None and not isinstance(
364
+ self.input_includes_cache, bool
365
+ ):
366
+ raise ValueError("input_includes_cache must be true, false or null")
341
367
  if self.cost_usd is not None and (
342
368
  isinstance(self.cost_usd, bool)
343
369
  or not isinstance(self.cost_usd, (int, float))
@@ -350,30 +376,74 @@ class Usage:
350
376
  self, "provider_details", _copy_json_value(self.provider_details)
351
377
  )
352
378
 
379
+ @classmethod
380
+ def from_dict(cls, data: Mapping[str, Any]) -> "Usage":
381
+ """The usage ``to_dict`` wrote, from this protocol version or another: a field it leaves out is None, and a
382
+ key this version doesn't know is ignored. Raises ValueError or TypeError for a field it can't hold."""
383
+ if not isinstance(data, Mapping):
384
+ raise TypeError("usage must be a mapping")
385
+ known = {
386
+ f.name: data[f.name]
387
+ for f in fields(cls)
388
+ if f.name != "provider_details" and data.get(f.name) is not None
389
+ }
390
+ details = data.get("provider_details")
391
+ return cls(**known, provider_details={} if details is None else details)
392
+
393
+ @classmethod
394
+ def from_model_response(cls, usage: Mapping[str, Any]) -> "Usage":
395
+ """A model call's usage as its response carried it, with ``input_tokens`` counting the cache: OpenAI's Chat
396
+ Completions (``prompt_tokens``) and Responses (``input_tokens``) shapes, and Anthropic's. An OpenAI count,
397
+ or a LiteLLM client's, says what it holds in its ``prompt_tokens_details`` or ``input_tokens_details``, whose
398
+ ``cached_tokens`` it counts, and ``cache_write_tokens`` with them. Anthropic's ``input_tokens``, and the
399
+ ``prompt_tokens`` a LiteLLM proxy sends with Anthropic's ``cache_read_input_tokens`` and
400
+ ``cache_creation_input_tokens`` beside it, count neither, so they're added, to ``total_tokens`` too. A
401
+ provider's split of its cache writes by how long they're kept (Anthropic's ``cache_creation``, OpenAI's
402
+ ``cache_write_tokens_details``), priced apart, is kept in ``provider_details``; so are the keys of a usage
403
+ in none of these shapes, as ``unrecognized``. A value that isn't a count is left out."""
404
+ key = "prompt_tokens" if "prompt_tokens" in usage else "input_tokens"
405
+ details = usage.get(f"{key}_details")
406
+ details = details if isinstance(details, Mapping) else {}
407
+ cached = _count(details.get("cached_tokens"))
408
+ read = cached if cached is not None else _count(usage.get("cache_read_input_tokens"))
409
+ written = _count(details.get("cache_write_tokens"))
410
+ write = written if written is not None else _count(usage.get("cache_creation_input_tokens"))
411
+ cache = (read or 0) + (write or 0)
412
+ input_tokens = _count(usage.get(key))
413
+ counts_cache = cached is not None and input_tokens is not None and input_tokens >= cache
414
+ missing = cache if input_tokens is not None and not counts_cache else 0
415
+ if input_tokens is not None:
416
+ input_tokens += missing
417
+ output = _count(usage.get("completion_tokens", usage.get("output_tokens")))
418
+ if (total := _count(usage.get("total_tokens"))) is not None:
419
+ total += missing
420
+ elif input_tokens is not None and output is not None:
421
+ total = input_tokens + output
422
+ kept = {"cache_creation": usage.get("cache_creation"),
423
+ "cache_write_tokens_details": details.get("cache_write_tokens_details")}
424
+ provider_details: dict[str, Any] = {
425
+ name: counts for name, split in kept.items() if isinstance(split, Mapping)
426
+ if (counts := {k: v for k, v in split.items() if _count(v) is not None})}
427
+ if usage and _RESPONSE_USAGE_KEYS.isdisjoint(usage):
428
+ provider_details["unrecognized"] = sorted(map(str, usage))
429
+ return cls(input_tokens=input_tokens, output_tokens=output, total_tokens=total, cache_read_tokens=read,
430
+ cache_write_tokens=write, input_includes_cache=True if input_tokens is not None else None,
431
+ provider_details=provider_details)
432
+
353
433
  @property
354
434
  def is_empty(self) -> bool:
355
- return (
356
- self.tool_call_count is None
357
- and self.input_tokens is None
358
- and self.output_tokens is None
359
- and self.total_tokens is None
360
- and self.cost_usd is None
361
- and not self.provider_details
362
- )
435
+ return all(value is None for value in self._values().values()) and not self.provider_details
363
436
 
364
437
  def to_dict(self) -> dict[str, Any]:
365
- values = {
366
- "tool_call_count": self.tool_call_count,
367
- "input_tokens": self.input_tokens,
368
- "output_tokens": self.output_tokens,
369
- "total_tokens": self.total_tokens,
370
- "cost_usd": self.cost_usd,
371
- }
372
- result = {name: value for name, value in values.items() if value is not None}
438
+ result = {name: value for name, value in self._values().items() if value is not None}
373
439
  if self.provider_details:
374
440
  result["provider_details"] = _thaw(self.provider_details)
375
441
  return result
376
442
 
443
+ def _values(self) -> dict[str, Any]:
444
+ """Every field but ``provider_details``, by name, in declaration order."""
445
+ return {f.name: getattr(self, f.name) for f in fields(self) if f.name != "provider_details"}
446
+
377
447
 
378
448
  @dataclass(frozen=True, slots=True, kw_only=True)
379
449
  class TaskResult:
@@ -438,11 +508,13 @@ class TaskResult:
438
508
  *,
439
509
  error_type: Literal["agent_error", "infra_error"] = "agent_error",
440
510
  parts: Iterable[TaskPart] | None = None,
511
+ usage: Usage | None = None,
441
512
  ) -> "TaskResult":
442
513
  return (
443
514
  cls.builder()
444
515
  .failed(code, message, error_type=error_type)
445
516
  .parts(parts if parts is not None else (TextPart(text=message),))
517
+ .usage(usage or Usage())
446
518
  .build()
447
519
  )
448
520
 
@@ -16,7 +16,7 @@ import uvicorn
16
16
  from starlette.testclient import TestClient
17
17
 
18
18
  from agentenv_protocol import EnvironmentCard, ToolContext, ToolSession, create_fastmcp_app, tool
19
- from agentenv_protocol.a2a_agent import ProxyActionState, proxy
19
+ from agentenv_protocol.a2a_agent import REPORTED_USAGE_KEY, ProxyActionState, Usage, proxy
20
20
  from agentenv_protocol.a2a_agent.proxy import ProxyAgent
21
21
 
22
22
  TOKEN = "t" * 32
@@ -578,6 +578,153 @@ def test_recorded_model_calls_are_checked_against_the_actions_that_run(client, e
578
578
  assert task["status"]["message"]["parts"][1]["data"]["usage"]["tool_call_count"] == 3
579
579
 
580
580
 
581
+ def _usage(task: dict[str, Any]) -> dict[str, Any]:
582
+ [usage] = [part["data"]["usage"] for part in task["status"]["message"]["parts"]
583
+ if part.get("kind") == "data" and "usage" in part["data"]]
584
+ return usage
585
+
586
+
587
+ def test_a_turns_usage_sums_its_recorded_calls_with_input_counting_the_cache(client):
588
+ task_id = _send(client, "go")
589
+ for usage in ({"prompt_tokens": 120, "completion_tokens": 7, "total_tokens": 127,
590
+ "prompt_tokens_details": {"cached_tokens": 100}},
591
+ {"input_tokens": 3, "output_tokens": 9, "cache_read_input_tokens": 100,
592
+ "cache_creation_input_tokens": 20},
593
+ {"prompt_tokens": 50, "completion_tokens": 1, "cache_read_input_tokens": 40,
594
+ "cache_creation_input_tokens": 10},
595
+ None):
596
+ assert _proxy(client, "record", task_id=task_id, message="Thinking.", usage=usage).status_code == 200
597
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
598
+
599
+ assert _usage(_settled(client, task_id)) == {
600
+ "tool_call_count": 0, "input_tokens": 120 + 123 + 100, "output_tokens": 17, "total_tokens": 127 + 132 + 101,
601
+ "cache_read_tokens": 240, "cache_write_tokens": 30, "input_includes_cache": True,
602
+ "provider_details": {"model_calls": 4, "unreported": {
603
+ "input_tokens": 1, "output_tokens": 1, "total_tokens": 1, "cache_read_tokens": 1, "cache_write_tokens": 2}}}
604
+
605
+
606
+ def test_counts_a_recorded_call_doesnt_give_or_cant_be_read_are_left_out(client):
607
+ task_id = _send(client, "go")
608
+ for usage in ({"prompt_tokens": "9", "completion_tokens": True, "prompt_tokens_details": "none"},
609
+ {"completion_tokens": 4}):
610
+ assert _proxy(client, "record", task_id=task_id, message="Thinking.", usage=usage).status_code == 200
611
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
612
+
613
+ assert _usage(_settled(client, task_id)) == {"tool_call_count": 0, "output_tokens": 4, "provider_details": {
614
+ "model_calls": 2, "unreported": {"output_tokens": 1}}}
615
+
616
+
617
+ def test_an_error_reply_keeps_the_usage_recorded_before_it(client):
618
+ task_id = _send(client, "go")
619
+ _proxy(client, "record", task_id=task_id, message="Thinking.", usage={"input_tokens": 5, "output_tokens": 2})
620
+ _proxy(client, "reply", task_id=task_id, error="the driver gave up")
621
+
622
+ task = _settled(client, task_id)
623
+ assert task["status"]["state"] == "failed"
624
+ assert _usage(task) == {"tool_call_count": 0, "input_tokens": 5, "output_tokens": 2, "total_tokens": 7,
625
+ "input_includes_cache": True, "provider_details": {"model_calls": 1}}
626
+
627
+
628
+ def test_a_chat_spans_counts_are_the_ones_the_turns_usage_sums(client):
629
+ task_id = _send(client, "go")
630
+ _proxy(client, "record", task_id=task_id, message="Thinking.", usage={
631
+ "prompt_tokens": 9, "completion_tokens": 5, "total_tokens": 14, "cache_read_input_tokens": 7809})
632
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
633
+
634
+ usage = _usage(_settled(client, task_id))
635
+ [chat, _] = _trajectory(client, task_id)
636
+ assert (chat["attributes"]["gen_ai.usage.input_tokens"], chat["attributes"]["gen_ai.usage.output_tokens"]) == (
637
+ usage["input_tokens"], usage["output_tokens"]) == (7818, 5)
638
+
639
+
640
+ def test_a_turn_with_no_recorded_calls_reports_only_its_tool_calls(client):
641
+ task_id = _send(client, "go")
642
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
643
+
644
+ assert _usage(_settled(client, task_id)) == {"tool_call_count": 0}
645
+
646
+
647
+ def _reported(usage: Usage) -> dict[str, Any]:
648
+ return {REPORTED_USAGE_KEY: usage.to_dict()}
649
+
650
+
651
+ def test_a_usage_its_driver_reports_is_taken_as_given_its_input_made_to_count_the_cache(client):
652
+ task_id = _send(client, "go")
653
+ for usage in (_reported(Usage(input_tokens=9, output_tokens=5, total_tokens=14, cache_read_tokens=7809,
654
+ input_includes_cache=False, cost_usd=0.25)),
655
+ _reported(Usage(input_tokens=100, output_tokens=1, cache_read_tokens=60, input_includes_cache=True,
656
+ cost_usd=0.5)),
657
+ _reported(Usage(input_tokens=4, output_tokens=1))):
658
+ assert _proxy(client, "record", task_id=task_id, message="Thinking.", usage=usage).status_code == 200
659
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
660
+
661
+ assert _usage(_settled(client, task_id)) == {
662
+ "tool_call_count": 0, "input_tokens": 7818 + 100 + 4, "output_tokens": 7, "total_tokens": 7823,
663
+ "cache_read_tokens": 7869, "input_includes_cache": True, "cost_usd": 0.75,
664
+ "provider_details": {"model_calls": 3, "unreported": {
665
+ "total_tokens": 2, "cache_read_tokens": 1, "cost_usd": 1}}}
666
+ [chat, *_] = _trajectory(client, task_id)
667
+ assert chat["attributes"]["gen_ai.usage.input_tokens"] == 7818
668
+
669
+
670
+ def test_a_reported_call_whose_input_may_or_may_not_hold_its_cache_leaves_the_turns_flag_unknown(client):
671
+ task_id = _send(client, "go")
672
+ _proxy(client, "record", task_id=task_id, message="Thinking.",
673
+ usage=_reported(Usage(input_tokens=9, output_tokens=5, cache_read_tokens=7809)))
674
+ _proxy(client, "record", task_id=task_id, message="Thinking.", usage={"prompt_tokens": 10, "completion_tokens": 1})
675
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
676
+
677
+ assert _usage(_settled(client, task_id)) == {
678
+ "tool_call_count": 0, "input_tokens": 19, "output_tokens": 6, "total_tokens": 11, "cache_read_tokens": 7809,
679
+ "provider_details": {"model_calls": 2, "unreported": {"total_tokens": 1, "cache_read_tokens": 1},
680
+ "cache_unsettled": 1}}
681
+
682
+
683
+ @pytest.mark.parametrize("reported", [{"input_tokens": -1}, {"input_includes_cache": "yes"}, ["input_tokens"],
684
+ {"provider_details": []}], ids=["negative", "flag", "not-a-mapping", "details"])
685
+ def test_a_reported_usage_that_isnt_one_is_refused_and_the_turn_left_as_it_was(client, reported):
686
+ task_id = _send(client, "go")
687
+
688
+ refused = _proxy(client, "record", task_id=task_id, message="Thinking.", usage={REPORTED_USAGE_KEY: reported})
689
+
690
+ assert refused.status_code == 400 and REPORTED_USAGE_KEY in refused.text
691
+ assert _proxy(client, "record", task_id=task_id, message="Thinking.",
692
+ usage={"input_tokens": 3, "output_tokens": 1}).status_code == 200
693
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
694
+ assert _usage(_settled(client, task_id))["provider_details"] == {"model_calls": 1}
695
+
696
+
697
+ def test_a_reported_usages_cache_write_split_counts_only_where_it_holds_counts(client):
698
+ task_id = _send(client, "go")
699
+ for details in ({"cache_creation": {"ephemeral_1h_input_tokens": None, "ephemeral_5m_input_tokens": 7}},
700
+ {"cache_creation": "x", "cache_write_tokens_details": [1, 2]},
701
+ {"cache_creation": {"ephemeral_5m_input_tokens": "3", "ephemeral_1h_input_tokens": True,
702
+ "other": -1}}):
703
+ usage = _reported(Usage(input_tokens=1, output_tokens=1, provider_details=details))
704
+ assert _proxy(client, "record", task_id=task_id, message="Thinking.", usage=usage).status_code == 200
705
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
706
+
707
+ task = _settled(client, task_id)
708
+ assert task["status"]["state"] == "completed"
709
+ assert _usage(task)["provider_details"] == {"model_calls": 3, "cache_creation": {"ephemeral_5m_input_tokens": 7}}
710
+
711
+
712
+ def test_a_turn_sums_each_providers_cache_write_split_and_counts_usage_it_couldnt_read(client):
713
+ task_id = _send(client, "go")
714
+ for usage in ({"input_tokens": 9, "output_tokens": 5, "cache_creation_input_tokens": 7813,
715
+ "cache_creation": {"ephemeral_1h_input_tokens": 7813, "ephemeral_5m_input_tokens": 0}},
716
+ {"input_tokens": 9, "output_tokens": 5, "cache_creation_input_tokens": 20,
717
+ "cache_creation": {"ephemeral_1h_input_tokens": 0, "ephemeral_5m_input_tokens": 20}},
718
+ {"inputTokens": 5, "outputTokens": 2}):
719
+ assert _proxy(client, "record", task_id=task_id, message="Thinking.", usage=usage).status_code == 200
720
+ _proxy(client, "reply", task_id=task_id, parts=[{"kind": "text", "text": "Done."}])
721
+
722
+ assert _usage(_settled(client, task_id))["provider_details"] == {
723
+ "model_calls": 3, "unrecognized": 1,
724
+ "unreported": {"input_tokens": 1, "output_tokens": 1, "total_tokens": 1, "cache_write_tokens": 1},
725
+ "cache_creation": {"ephemeral_1h_input_tokens": 7813, "ephemeral_5m_input_tokens": 20}}
726
+
727
+
581
728
  def test_an_env_tool_named_bash_is_held_to_all_its_recorded_arguments(terminal, monkeypatch, tmp_path):
582
729
  monkeypatch.chdir(tmp_path)
583
730
  with TestClient(ProxyAgent(shell=False, long_poll_seconds=0.2).create_app()) as client: