Skip to content

Implement chat compaction API and separate resume endpoints - #30

Merged
MegumiinUwU merged 4 commits into
mainfrom
dev
Jun 29, 2026
Merged

Implement chat compaction API and separate resume endpoints#30
MegumiinUwU merged 4 commits into
mainfrom
dev

Conversation

@MegumiinUwU

Copy link
Copy Markdown
Collaborator

No description provided.

Hemdan47 added 4 commits June 27, 2026 18:50
- Add `POST /compact` endpoint to summarize conversation history
- Implement compaction service with LLM-based summary merging logic
- Add request and response validation schemas (`CompactRequest`, `CompactResponse`)
- Create integration tests for schema validation and message ordering
…validation

Replace generic /stream/resume endpoint with type-specific endpoints for permission and clarification responses. Emit dedicated event types (permission.required, clarification.required) instead of generic input.required.

Breaking Changes:
- Remove /generate/{thread_id}/stream/resume endpoint
- Remove input.required event type
- Remove ResumeRequest schema

New Endpoints:
- POST /generate/{thread_id}/resume/permission
  - Validates request_id matches pending permission request
  - Returns 409 on request_id mismatch (prevents race conditions)
  - Accepts: decision (allow|deny), request_id, llm
- POST /generate/{thread_id}/resume/clarification
  - No request_id required (low-risk, simpler API)
  - Accepts: answer (string), llm

New Event Types:
- permission.required: Emits request_id, command, cmd_type, message, source
- clarification.required: Emits question, source

Benefits:
- Type safety: Explicit Literal["allow", "deny"] for permissions
- Race condition prevention: request_id validation ensures correct question answered
- Clear API contracts: Separate endpoints for different interrupt types
- Better error messages: 409 Conflict with specific validation failures
- Extensible: Easy to add new interrupt types (confirmation.required, choice.required)
- Add `reasoning_effort` configuration to `LLMConfig` to control thinking budget
- Introduce `assistant.thinking` event type to stream reasoning text
- Emit thinking events in Planner, Generator, and Analyzer nodes
- Centralize raw response unwrapping and retry handling in LLM resilience wrapper
- Update unit and integration tests to support async execution and verify thinking events
- Refactor `writer_node` to support a two-phase state machine: Phase 1 emits the generated YAML draft event (`yaml.draft`) for preview and prompts for write permission, pausing the graph. Phase 2 checks the user's decision (writes to disk on allow; routes to planner on deny).
- Update the supervisor node conditional routing to direct draft completions to `writer_node` instead of terminating.
- Update the planner node to detect when a draft is rejected (`write_rejected`), prompting the user for clarification on what to change.
- Centralize `permission_answer_for_request` logic inside tools permission protocol module.
- Add comprehensive unit tests covering the two-phase writer flow (draft preview, approval write, denial replan).
@MegumiinUwU
MegumiinUwU merged commit 16b152a into main Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants