Copilot SDK for Java 1.0.7: 세션 라이프사이클 훅 및 향상된 관측성
Source: Dev.to
What’s New in 1.0.7
Session Lifecycle Hooks
이번 릴리즈에서 가장 큰 추가 사항은 확장된 훅 시스템입니다. v1.0.6에서 pre‑tool 및 post‑tool 훅을 도입했지만, v1.0.7에서는 세 가지 새로운 라이프사이클 훅을 추가해 세션 동작을 세밀하게 제어할 수 있게 했습니다.
onSessionStart
세션이 시작될 때(새로 시작하거나 재개될 때) 호출됩니다. 세션이 실제 처리를 시작하기 전에 초기화, 로깅, 검증 등에 사용할 수 있습니다.
var config = new SessionConfig()
.setOnSessionStart((input, invocation) -> {
System.out.println("Session started: " + input.getSessionId());
// Initialize session‑specific resources
return CompletableFuture.completedFuture(
new SessionStartHookOutput()
);
});
onSessionEnd
세션이 종료될 때 호출되어 정리 작업, 메트릭 수집, 감사 로그 등을 수행할 수 있습니다.
.setOnSessionEnd((input, invocation) -> {
Duration sessionDuration = calculateDuration(input);
metricsCollector.recordSessionDuration(sessionDuration);
return CompletableFuture.completedFuture(
new SessionEndHookOutput()
);
})
onUserPromptSubmitted
사용자가 프롬프트를 제출할 때 호출되며, 프롬프트를 풍부하게 만들거나 검증·변환하는 데 활용할 수 있습니다.
.setOnUserPromptSubmitted((input, invocation) -> {
String enrichedPrompt = addProjectContext(input.getPrompt());
return CompletableFuture.completedFuture(
new UserPromptSubmittedHookOutput()
.setUpdatedPrompt(enrichedPrompt)
);
})
이러한 훅을 활용하면 다음과 같은 강력한 사용 사례를 구현할 수 있습니다.
- Security gates – 실행 전에 허용 목록을 기준으로 도구 호출을 검증합니다.
- Audit logging – 규정 준수를 위해 모든 도구 호출을 기록합니다.
- Result enrichment – 메타데이터를 추가하거나 도구 출력 결과를 변환합니다.
- Session analytics – 세션 패턴 및 사용자 행동을 추적합니다.
Client‑Level Lifecycle Events
세션 범위 훅 외에도, v1.0.7은 다중 동시 세션을 관리하는 애플리케이션에 유용한 클라이언트 수준 라이프사이클 이벤트 구독을 도입했습니다.
// Subscribe to all lifecycle events
client.onLifecycle(event -> {
System.out.println("Session " + event.getSessionId() +
" status: " + event.getType());
});
// Subscribe to specific event types
client.onLifecycle(SessionLifecycleEventTypes.CREATED, event -> {
initializeSessionResources(event.getSessionId());
});
client.onLifecycle(SessionLifecycleEventTypes.DELETED, event -> {
cleanupSessionResources(event.getSessionId());
});
Available event types
| Type | Description |
|---|---|
CREATED | A new session was created |
DELETED | A session was deleted |
UPDATED | Session state was updated |
FOREGROUND | Session moved to foreground (TUI mode) |
BACKGROUND | Session moved to background (TUI mode) |
Foreground Session Control
TUI + Server 모드(copilot --ui-server)로 실행되는 애플리케이션을 위해 v1.0.7은 터미널 UI에 표시되는 세션을 제어하는 API를 추가했습니다.
// Get the currently displayed session
String currentSession = client.getForegroundSessionId();
// Switch the TUI to display a different session
client.setForegroundSessionId(anotherSessionId);
이를 통해 사용자 활동이나 우선순위에 따라 프로그램matically TUI 포커스를 전환할 수 있는 정교한 다중 세션 오케스트레이터를 구축할 수 있습니다.
New Event Types
관측성을 높이는 두 가지 새로운 이벤트 타입이 추가되었습니다.
SessionShutdownEvent
세션이 종료될 때 발생하며, 종료 이유와 종료 코드를 포함합니다.
session.on(SessionShutdownEvent.class, event -> {
System.out.println("Session shutting down: " +
event.getData().getReason());
});
SkillInvokedEvent
스킬이 호출될 때 발생하며, includes the skil
Source: …
Skill name 및 호출 컨텍스트:
session.on(SkillInvokedEvent.class, event -> {
System.out.println("Skill invoked: " +
event.getData().getSkillName());
});
확장된 이벤트 데이터
몇몇 기존 이벤트에 추가 필드가 포함되었습니다:
| 이벤트 | 새 필드 |
|---|---|
AssistantMessageEvent | id, isLastReply, thinkingContent |
AssistantUsageEvent | outputReasoningTokens |
SessionCompactionCompleteEvent | success, messagesRemoved, tokensRemoved |
SessionErrorEvent | 확장된 오류 컨텍스트 |
JaCoCo 테스트 커버리지
이번 릴리스에서는 JaCoCo 0.8.14를 통합하여 테스트 커버리지를 보고합니다. 커버리지 보고서는 이제 다음과 같이 제공됩니다:
- 빌드 시 자동으로
target/site/jacoco-coverage/에 생성됩니다. - GitHub Actions 워크플로 요약에 요약됩니다.
- 상세 분석을 위해 CI 아티팩트로 업로드됩니다.
문서 개선
문서가 크게 확장되었습니다:
- Session Hooks Guide – 다섯 가지 훅 유형을 모두 다루는 포괄적인 가이드와 실용적인 예제.
- Events Reference – 33가지 이벤트 유형 전체에 대한 완전한 문서.
- Advanced Usage – 라이프사이클 이벤트와 포그라운드 세션 제어가 강화된 내용.
Breaking Changes
여기에 파괴적 변경 사항이 나열됩니다. (필요에 따라 구체적인 항목을 추가하세요.)
# Copilot CLI
**Minimum required version updated from 0.0.400 to 0.0.404**
시작하기
pom.xml에 의존성을 추가하세요:
<dependency>
<groupId>com.github.copilot-community-sdk</groupId>
<artifactId>copilot-sdk-java</artifactId>
<version>1.0.7</version>
</dependency>
또는 JBang으로 즉시 사용해 보세요:
jbang https://github.com/copilot-community-sdk/copilot-sdk-java/blob/main/jbang-example.java
What’s Next
우리는 공식 .NET SDK를 지속적으로 추적하고 새로운 기능이 제공되는 대로 포팅합니다. 향후 우선순위는 다음과 같습니다:
- Additional MCP server integrations
- Enhanced error recovery patterns
- Performance optimizations for high‑throughput scenarios
기여
Copilot SDK for Java은 커뮤니티 주도 프로젝트이며, 여러분의 기여를 환영합니다!
저장소를 탐색하고 기여 가이드를 읽어보세요:
- Repository: https://github.com/copilot-community-sdk/copilot-sdk-java
- Guidelines: https://github.com/copilot-community-sdk/copilot-sdk-java/blob/main/CONTRIBUTING.md
유용한 링크
- Release notes: https://github.com/copilot-community-sdk/copilot-sdk-java/releases/tag/v1.0.7
- Full changelog: https://github.com/copilot-community-sdk/copilot-sdk-java/blob/main/CHANGELOG.md
- Documentation: https://copilot-community-sdk.github.io/copilot-sdk-java/
- Maven Central: https://central.sonatype.com/artifact/com.github.copilot-community-sdk/copilot-sdk-java
게시일: February 5, 2026