From e0e1a48e7371b75ce7585420fe244807d76873d1 Mon Sep 17 00:00:00 2001 From: Rohan Satkar Date: Wed, 4 Feb 2026 16:04:16 +0530 Subject: [PATCH 1/2] fix(python): populate usage_info when resuming session --- python/copilot/client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/copilot/client.py b/python/copilot/client.py index da1ba8c0..d0cea93b 100644 --- a/python/copilot/client.py +++ b/python/copilot/client.py @@ -634,6 +634,9 @@ async def resume_session( resumed_session_id = response["sessionId"] workspace_path = response.get("workspacePath") session = CopilotSession(resumed_session_id, self._client, workspace_path) + usage_info = response.get("usageInfo") or response.get("usage_info") + if usage_info: + session.usage_info = usage_info session._register_tools(cfg.get("tools")) if on_permission_request: session._register_permission_handler(on_permission_request) From 1738727b6250b7fa5a6848c6eb7190ec9e0b2900 Mon Sep 17 00:00:00 2001 From: Rohan Satkar Date: Wed, 4 Feb 2026 16:15:05 +0530 Subject: [PATCH 2/2] fix(python): persist usage_info on session create/resume and update via events --- python/copilot/client.py | 5 ++++- python/copilot/session.py | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/python/copilot/client.py b/python/copilot/client.py index d0cea93b..a57502f7 100644 --- a/python/copilot/client.py +++ b/python/copilot/client.py @@ -504,6 +504,9 @@ async def create_session(self, config: Optional[SessionConfig] = None) -> Copilo session_id = response["sessionId"] workspace_path = response.get("workspacePath") session = CopilotSession(session_id, self._client, workspace_path) + usage_info = response.get("usageInfo") + if usage_info: + session.usage_info = usage_info session._register_tools(tools) if on_permission_request: session._register_permission_handler(on_permission_request) @@ -634,7 +637,7 @@ async def resume_session( resumed_session_id = response["sessionId"] workspace_path = response.get("workspacePath") session = CopilotSession(resumed_session_id, self._client, workspace_path) - usage_info = response.get("usageInfo") or response.get("usage_info") + usage_info = response.get("usageInfo") if usage_info: session.usage_info = usage_info session._register_tools(cfg.get("tools")) diff --git a/python/copilot/session.py b/python/copilot/session.py index fb39e9fc..8a8cce64 100644 --- a/python/copilot/session.py +++ b/python/copilot/session.py @@ -79,6 +79,7 @@ def __init__(self, session_id: str, client: Any, workspace_path: Optional[str] = self._user_input_handler_lock = threading.Lock() self._hooks: Optional[SessionHooks] = None self._hooks_lock = threading.Lock() + self.usage_info = None @property def workspace_path(self) -> Optional[str]: @@ -232,6 +233,9 @@ def _dispatch_event(self, event: SessionEvent) -> None: Args: event: The session event to dispatch to all handlers. """ + if hasattr(event, "usage_info") and event.usage_info: + self.usage_info = event.usage_info + with self._event_handlers_lock: handlers = list(self._event_handlers)