Skip to content

Commit 2055997

Browse files
Regenerate types for session.usage_info and apply PR feedback
1 parent f23a4ca commit 2055997

File tree

6 files changed

+60
-14
lines changed

6 files changed

+60
-14
lines changed

dotnet/src/Generated/SessionEvents.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Generated from: @github/copilot/session-events.schema.json
88
// Generated by: scripts/generate-session-types.ts
9-
// Generated at: 2026-01-15T19:22:26.479Z
9+
// Generated at: 2026-01-16T00:52:52.781Z
1010
//
1111
// To update these types:
1212
// 1. Update the schema in copilot-agent-runtime
@@ -39,6 +39,7 @@ internal class SessionEventConverter : JsonConverter<SessionEvent>
3939
["session.model_change"] = typeof(SessionModelChangeEvent),
4040
["session.handoff"] = typeof(SessionHandoffEvent),
4141
["session.truncation"] = typeof(SessionTruncationEvent),
42+
["session.usage_info"] = typeof(SessionUsageInfoEvent),
4243
["session.compaction_start"] = typeof(SessionCompactionStartEvent),
4344
["session.compaction_complete"] = typeof(SessionCompactionCompleteEvent),
4445
["user.message"] = typeof(UserMessageEvent),
@@ -209,6 +210,17 @@ public partial class SessionTruncationEvent : SessionEvent
209210
public SessionTruncationData Data { get; set; }
210211
}
211212

213+
/// <summary>
214+
/// Event: session.usage_info
215+
/// </summary>
216+
public partial class SessionUsageInfoEvent : SessionEvent
217+
{
218+
public override string Type => "session.usage_info";
219+
220+
[JsonPropertyName("data")]
221+
public SessionUsageInfoData Data { get; set; }
222+
}
223+
212224
/// <summary>
213225
/// Event: session.compaction_start
214226
/// </summary>
@@ -592,6 +604,18 @@ public partial class SessionTruncationData
592604
public string PerformedBy { get; set; }
593605
}
594606

607+
public partial class SessionUsageInfoData
608+
{
609+
[JsonPropertyName("tokenLimit")]
610+
public double TokenLimit { get; set; }
611+
612+
[JsonPropertyName("currentTokens")]
613+
public double CurrentTokens { get; set; }
614+
615+
[JsonPropertyName("messagesLength")]
616+
public double MessagesLength { get; set; }
617+
}
618+
595619
public partial class SessionCompactionStartData
596620
{
597621
}

go/generated/session_events.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/src/generated/session-events.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Generated from: @github/copilot/session-events.schema.json
55
* Generated by: scripts/generate-session-types.ts
6-
* Generated at: 2026-01-15T19:22:25.859Z
6+
* Generated at: 2026-01-16T00:52:51.450Z
77
*
88
* To update these types:
99
* 1. Update the schema in copilot-agent-runtime
@@ -115,6 +115,18 @@ export type SessionEvent =
115115
performedBy: string;
116116
};
117117
}
118+
| {
119+
id: string;
120+
timestamp: string;
121+
parentId: string | null;
122+
ephemeral: true;
123+
type: "session.usage_info";
124+
data: {
125+
tokenLimit: number;
126+
currentTokens: number;
127+
messagesLength: number;
128+
};
129+
}
118130
| {
119131
id: string;
120132
timestamp: string;

nodejs/test/e2e/harness/sdkTestContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export async function createSdkTestContext() {
5151

5252
// Wire up to Vitest lifecycle
5353
beforeEach(async (testContext) => {
54+
// Must be inside beforeEach - vitest requires test context
5455
onTestFailed(() => {
5556
anyTestFailed = true;
5657
});

python/copilot/generated/session_events.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Generated from: @github/copilot/session-events.schema.json
55
Generated by: scripts/generate-session-types.ts
6-
Generated at: 2026-01-15T19:22:26.227Z
6+
Generated at: 2026-01-16T00:52:51.909Z
77
88
To update these types:
99
1. Update the schema in copilot-agent-runtime
@@ -314,6 +314,8 @@ class Data:
314314
pre_truncation_tokens_in_messages: Optional[float] = None
315315
token_limit: Optional[float] = None
316316
tokens_removed_during_truncation: Optional[float] = None
317+
current_tokens: Optional[float] = None
318+
messages_length: Optional[float] = None
317319
compaction_tokens_used: Optional[CompactionTokensUsed] = None
318320
error: Optional[Union[ErrorClass, str]] = None
319321
messages_removed: Optional[float] = None
@@ -397,6 +399,8 @@ def from_dict(obj: Any) -> 'Data':
397399
pre_truncation_tokens_in_messages = from_union([from_float, from_none], obj.get("preTruncationTokensInMessages"))
398400
token_limit = from_union([from_float, from_none], obj.get("tokenLimit"))
399401
tokens_removed_during_truncation = from_union([from_float, from_none], obj.get("tokensRemovedDuringTruncation"))
402+
current_tokens = from_union([from_float, from_none], obj.get("currentTokens"))
403+
messages_length = from_union([from_float, from_none], obj.get("messagesLength"))
400404
compaction_tokens_used = from_union([CompactionTokensUsed.from_dict, from_none], obj.get("compactionTokensUsed"))
401405
error = from_union([ErrorClass.from_dict, from_str, from_none], obj.get("error"))
402406
messages_removed = from_union([from_float, from_none], obj.get("messagesRemoved"))
@@ -448,7 +452,7 @@ def from_dict(obj: Any) -> 'Data':
448452
metadata = from_union([Metadata.from_dict, from_none], obj.get("metadata"))
449453
name = from_union([from_str, from_none], obj.get("name"))
450454
role = from_union([Role, from_none], obj.get("role"))
451-
return Data(copilot_version, producer, selected_model, session_id, start_time, version, event_count, resume_time, error_type, message, stack, info_type, new_model, previous_model, context, handoff_time, remote_session_id, repository, source_type, summary, messages_removed_during_truncation, performed_by, post_truncation_messages_length, post_truncation_tokens_in_messages, pre_truncation_messages_length, pre_truncation_tokens_in_messages, token_limit, tokens_removed_during_truncation, compaction_tokens_used, error, messages_removed, post_compaction_tokens, pre_compaction_messages_length, pre_compaction_tokens, success, summary_content, tokens_removed, attachments, content, source, transformed_content, turn_id, intent, reasoning_id, delta_content, message_id, parent_tool_call_id, tool_requests, total_response_size_bytes, api_call_id, cache_read_tokens, cache_write_tokens, cost, duration, initiator, input_tokens, model, output_tokens, provider_call_id, quota_snapshots, reason, arguments, tool_call_id, tool_name, partial_output, is_user_requested, result, tool_telemetry, agent_description, agent_display_name, agent_name, tools, hook_invocation_id, hook_type, input, output, metadata, name, role)
455+
return Data(copilot_version, producer, selected_model, session_id, start_time, version, event_count, resume_time, error_type, message, stack, info_type, new_model, previous_model, context, handoff_time, remote_session_id, repository, source_type, summary, messages_removed_during_truncation, performed_by, post_truncation_messages_length, post_truncation_tokens_in_messages, pre_truncation_messages_length, pre_truncation_tokens_in_messages, token_limit, tokens_removed_during_truncation, current_tokens, messages_length, compaction_tokens_used, error, messages_removed, post_compaction_tokens, pre_compaction_messages_length, pre_compaction_tokens, success, summary_content, tokens_removed, attachments, content, source, transformed_content, turn_id, intent, reasoning_id, delta_content, message_id, parent_tool_call_id, tool_requests, total_response_size_bytes, api_call_id, cache_read_tokens, cache_write_tokens, cost, duration, initiator, input_tokens, model, output_tokens, provider_call_id, quota_snapshots, reason, arguments, tool_call_id, tool_name, partial_output, is_user_requested, result, tool_telemetry, agent_description, agent_display_name, agent_name, tools, hook_invocation_id, hook_type, input, output, metadata, name, role)
452456

453457
def to_dict(self) -> dict:
454458
result: dict = {}
@@ -508,6 +512,10 @@ def to_dict(self) -> dict:
508512
result["tokenLimit"] = from_union([to_float, from_none], self.token_limit)
509513
if self.tokens_removed_during_truncation is not None:
510514
result["tokensRemovedDuringTruncation"] = from_union([to_float, from_none], self.tokens_removed_during_truncation)
515+
if self.current_tokens is not None:
516+
result["currentTokens"] = from_union([to_float, from_none], self.current_tokens)
517+
if self.messages_length is not None:
518+
result["messagesLength"] = from_union([to_float, from_none], self.messages_length)
511519
if self.compaction_tokens_used is not None:
512520
result["compactionTokensUsed"] = from_union([lambda x: to_class(CompactionTokensUsed, x), from_none], self.compaction_tokens_used)
513521
if self.error is not None:
@@ -636,6 +644,7 @@ class SessionEventType(Enum):
636644
SESSION_RESUME = "session.resume"
637645
SESSION_START = "session.start"
638646
SESSION_TRUNCATION = "session.truncation"
647+
SESSION_USAGE_INFO = "session.usage_info"
639648
SUBAGENT_COMPLETED = "subagent.completed"
640649
SUBAGENT_FAILED = "subagent.failed"
641650
SUBAGENT_SELECTED = "subagent.selected"

python/e2e/conftest.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,26 @@
55

66
from .testharness import E2ETestContext
77

8-
# Track if any test failed to avoid writing corrupted snapshots
9-
_any_test_failed = False
10-
118

129
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
1310
def pytest_runtest_makereport(item, call):
1411
"""Track test failures to avoid writing corrupted snapshots."""
15-
global _any_test_failed
1612
outcome = yield
1713
rep = outcome.get_result()
1814
if rep.when == "call" and rep.failed:
19-
_any_test_failed = True
15+
# Store on the item's stash so the fixture can access it
16+
item.session.stash.setdefault("any_test_failed", False)
17+
item.session.stash["any_test_failed"] = True
2018

2119

2220
@pytest_asyncio.fixture(scope="module", loop_scope="module")
23-
async def ctx():
21+
async def ctx(request):
2422
"""Create and teardown a test context shared across all tests in this module."""
25-
global _any_test_failed
26-
_any_test_failed = False # Reset for each module
2723
context = E2ETestContext()
2824
await context.setup()
2925
yield context
30-
await context.teardown(test_failed=_any_test_failed)
26+
any_failed = request.session.stash.get("any_test_failed", False)
27+
await context.teardown(test_failed=any_failed)
3128

3229

3330
@pytest_asyncio.fixture(autouse=True, loop_scope="module")

0 commit comments

Comments
 (0)