Skip to content

Commit 4cc575d

Browse files
committed
Add session.context_changed event to SDK types
Adds the session.context_changed event to generated session event types in all SDK clients (Node.js, Python, Go, .NET). The event fires when the working directory context changes between turns and contains the updated context (cwd, gitRoot, repository, branch).
1 parent 7ce7ae3 commit 4cc575d

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

dotnet/src/Generated/SessionEvents.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace GitHub.Copilot.SDK;
4141
[JsonDerivedType(typeof(SessionHandoffEvent), "session.handoff")]
4242
[JsonDerivedType(typeof(SessionIdleEvent), "session.idle")]
4343
[JsonDerivedType(typeof(SessionInfoEvent), "session.info")]
44+
[JsonDerivedType(typeof(SessionContextChangedEvent), "session.context_changed")]
4445
[JsonDerivedType(typeof(SessionModelChangeEvent), "session.model_change")]
4546
[JsonDerivedType(typeof(SessionResumeEvent), "session.resume")]
4647
[JsonDerivedType(typeof(SessionShutdownEvent), "session.shutdown")]
@@ -148,6 +149,18 @@ public partial class SessionInfoEvent : SessionEvent
148149
public required SessionInfoData Data { get; set; }
149150
}
150151

152+
/// <summary>
153+
/// Event: session.context_changed
154+
/// </summary>
155+
public partial class SessionContextChangedEvent : SessionEvent
156+
{
157+
[JsonIgnore]
158+
public override string Type => "session.context_changed";
159+
160+
[JsonPropertyName("data")]
161+
public required SessionContextChangedData Data { get; set; }
162+
}
163+
151164
/// <summary>
152165
/// Event: session.model_change
153166
/// </summary>
@@ -605,6 +618,24 @@ public partial class SessionInfoData
605618
public required string Message { get; set; }
606619
}
607620

621+
public partial class SessionContextChangedData
622+
{
623+
[JsonPropertyName("cwd")]
624+
public required string Cwd { get; set; }
625+
626+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
627+
[JsonPropertyName("gitRoot")]
628+
public string? GitRoot { get; set; }
629+
630+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
631+
[JsonPropertyName("repository")]
632+
public string? Repository { get; set; }
633+
634+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
635+
[JsonPropertyName("branch")]
636+
public string? Branch { get; set; }
637+
}
638+
608639
public partial class SessionModelChangeData
609640
{
610641
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
@@ -1425,6 +1456,8 @@ public enum SystemMessageDataRole
14251456
[JsonSerializable(typeof(SessionIdleEvent))]
14261457
[JsonSerializable(typeof(SessionInfoData))]
14271458
[JsonSerializable(typeof(SessionInfoEvent))]
1459+
[JsonSerializable(typeof(SessionContextChangedData))]
1460+
[JsonSerializable(typeof(SessionContextChangedEvent))]
14281461
[JsonSerializable(typeof(SessionModelChangeData))]
14291462
[JsonSerializable(typeof(SessionModelChangeEvent))]
14301463
[JsonSerializable(typeof(SessionResumeData))]

go/generated_session_events.go

Lines changed: 4 additions & 0 deletions
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ export type SessionEvent =
8282
message: string;
8383
};
8484
}
85+
| {
86+
id: string;
87+
timestamp: string;
88+
parentId: string | null;
89+
ephemeral?: boolean;
90+
type: "session.context_changed";
91+
data: {
92+
cwd: string;
93+
gitRoot?: string;
94+
repository?: string;
95+
branch?: string;
96+
};
97+
}
8598
| {
8699
id: string;
87100
timestamp: string;

python/copilot/generated/session_events.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ class Data:
508508
stack: Optional[str] = None
509509
status_code: Optional[int] = None
510510
info_type: Optional[str] = None
511+
cwd: Optional[str] = None
512+
git_root: Optional[str] = None
513+
branch: Optional[str] = None
511514
new_model: Optional[str] = None
512515
previous_model: Optional[str] = None
513516
handoff_time: Optional[datetime] = None
@@ -615,6 +618,9 @@ def from_dict(obj: Any) -> 'Data':
615618
stack = from_union([from_str, from_none], obj.get("stack"))
616619
status_code = from_union([from_int, from_none], obj.get("statusCode"))
617620
info_type = from_union([from_str, from_none], obj.get("infoType"))
621+
cwd = from_union([from_str, from_none], obj.get("cwd"))
622+
git_root = from_union([from_str, from_none], obj.get("gitRoot"))
623+
branch = from_union([from_str, from_none], obj.get("branch"))
618624
new_model = from_union([from_str, from_none], obj.get("newModel"))
619625
previous_model = from_union([from_str, from_none], obj.get("previousModel"))
620626
handoff_time = from_union([from_datetime, from_none], obj.get("handoffTime"))
@@ -703,7 +709,7 @@ def from_dict(obj: Any) -> 'Data':
703709
output = obj.get("output")
704710
metadata = from_union([Metadata.from_dict, from_none], obj.get("metadata"))
705711
role = from_union([Role, from_none], obj.get("role"))
706-
return Data(context, copilot_version, producer, selected_model, session_id, start_time, version, event_count, resume_time, error_type, message, provider_call_id, stack, status_code, info_type, new_model, previous_model, 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, events_removed, up_to_event_id, code_changes, current_model, error_reason, model_metrics, session_start_time, shutdown_type, total_api_duration_ms, total_premium_requests, current_tokens, messages_length, checkpoint_number, checkpoint_path, compaction_tokens_used, error, messages_removed, post_compaction_tokens, pre_compaction_messages_length, pre_compaction_tokens, request_id, success, summary_content, tokens_removed, attachments, content, source, transformed_content, turn_id, intent, reasoning_id, delta_content, encrypted_content, message_id, parent_tool_call_id, reasoning_opaque, reasoning_text, tool_requests, total_response_size_bytes, api_call_id, cache_read_tokens, cache_write_tokens, cost, duration, initiator, input_tokens, model, output_tokens, quota_snapshots, reason, arguments, tool_call_id, tool_name, mcp_server_name, mcp_tool_name, partial_output, progress_message, is_user_requested, result, tool_telemetry, allowed_tools, name, path, agent_description, agent_display_name, agent_name, tools, hook_invocation_id, hook_type, input, output, metadata, role)
712+
return Data(context, copilot_version, producer, selected_model, session_id, start_time, version, event_count, resume_time, error_type, message, provider_call_id, stack, status_code, info_type, cwd, git_root, branch, new_model, previous_model, 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, events_removed, up_to_event_id, code_changes, current_model, error_reason, model_metrics, session_start_time, shutdown_type, total_api_duration_ms, total_premium_requests, current_tokens, messages_length, checkpoint_number, checkpoint_path, compaction_tokens_used, error, messages_removed, post_compaction_tokens, pre_compaction_messages_length, pre_compaction_tokens, request_id, success, summary_content, tokens_removed, attachments, content, source, transformed_content, turn_id, intent, reasoning_id, delta_content, encrypted_content, message_id, parent_tool_call_id, reasoning_opaque, reasoning_text, tool_requests, total_response_size_bytes, api_call_id, cache_read_tokens, cache_write_tokens, cost, duration, initiator, input_tokens, model, output_tokens, quota_snapshots, reason, arguments, tool_call_id, tool_name, mcp_server_name, mcp_tool_name, partial_output, progress_message, is_user_requested, result, tool_telemetry, allowed_tools, name, path, agent_description, agent_display_name, agent_name, tools, hook_invocation_id, hook_type, input, output, metadata, role)
707713

708714
def to_dict(self) -> dict:
709715
result: dict = {}
@@ -737,6 +743,12 @@ def to_dict(self) -> dict:
737743
result["statusCode"] = from_union([from_int, from_none], self.status_code)
738744
if self.info_type is not None:
739745
result["infoType"] = from_union([from_str, from_none], self.info_type)
746+
if self.cwd is not None:
747+
result["cwd"] = from_union([from_str, from_none], self.cwd)
748+
if self.git_root is not None:
749+
result["gitRoot"] = from_union([from_str, from_none], self.git_root)
750+
if self.branch is not None:
751+
result["branch"] = from_union([from_str, from_none], self.branch)
740752
if self.new_model is not None:
741753
result["newModel"] = from_union([from_str, from_none], self.new_model)
742754
if self.previous_model is not None:
@@ -935,6 +947,7 @@ class SessionEventType(Enum):
935947
SESSION_HANDOFF = "session.handoff"
936948
SESSION_IDLE = "session.idle"
937949
SESSION_INFO = "session.info"
950+
SESSION_CONTEXT_CHANGED = "session.context_changed"
938951
SESSION_MODEL_CHANGE = "session.model_change"
939952
SESSION_RESUME = "session.resume"
940953
SESSION_SHUTDOWN = "session.shutdown"

0 commit comments

Comments
 (0)