Skip to content

feat(client): add kai-agent backend support — new endpoints and approval flow#39

Merged
jordanrburger merged 2 commits into
mainfrom
feat/kai-agent-backend-integration
May 12, 2026
Merged

feat(client): add kai-agent backend support — new endpoints and approval flow#39
jordanrburger merged 2 commits into
mainfrom
feat/kai-agent-backend-integration

Conversation

@Matovidlo

Copy link
Copy Markdown
Contributor

Release Notes

  • Adds submit_approval() method using the new dedicated POST /api/chat/{id}/approval endpoint — replaces the complex Vercel AI SDK v6 approval protocol
  • Adds get_usage() to retrieve rate-limit usage (messages used, limit, reset date)
  • Adds get_settings() / update_settings() for project-level custom instructions
  • Adds get_user_settings() / update_user_settings() for user-level custom instructions and tool permissions
  • Adds get_tools() to list available MCP tools with read-only flags
  • Adds get_suggestions() for AI-generated contextual suggestions (dashboard, job-detail, configuration-detail)
  • Deprecates old v6 approval methods (approve_tool, reject_tool, send_tool_approval_response, send_tool_result, confirm_tool, deny_tool, resume_stream) — they are incompatible with the new backend

Plans for customer communication

None.

Impact analysis

  • KaiClient: 8 new public methods added — fully backwards-compatible, no existing API changed
  • models.py: 8 new response models (ApprovalResponse, UsageResponse, AgentSettings, UserAgentSettings, ToolInfo, ToolsListResponse, Suggestion, SuggestionsResponse) — all exported from __init__.py
  • Approval flow change: the new submit_approval() is a non-streaming POST that unblocks the live SSE stream still connected from send_message(), matching the kai-agent backend's in-memory approval store design
  • Deprecated methods still exist and still compile — no breaking changes for existing callers
  • 28 new tests added, all 89 tests pass

Change type

Feature — Connect kai-client to the new kai-agent backend

Justification

The kai-agent backend (keboola/ui apps/kai-agent) is a new Hono-based server replacing the old Vercel AI SDK v6 backend. It exposes several new endpoint groups (usage, settings, suggestions) and uses a fundamentally different tool approval mechanism: instead of re-POSTing a mutated assistant message, callers now submit approval decisions via a dedicated side-channel endpoint while the original SSE stream stays connected and resumes automatically.

Deployment

Merge & automatic deploy.

Rollback plan

Revert of this PR.

Post release support plan

None.

@Matovidlo Matovidlo requested review from Copilot May 11, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds kai-agent backend support to kai-client by introducing new client methods, response models, and tests for the new endpoint groups (approval side-channel, usage, settings, tools, suggestions), while marking legacy Vercel AI SDK v6 approval helpers as deprecated in docstrings.

Changes:

  • Added KaiClient.submit_approval() for the new non-streaming POST /api/chat/{id}/approval flow, plus new client methods for usage, settings, tools, and suggestions endpoints.
  • Introduced new Pydantic response models for the added endpoints and exported them from kai_client.
  • Added a comprehensive set of tests covering the new endpoints and request payloads/headers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/kai_client/client.py Adds new public client methods for kai-agent endpoints and updates legacy approval method docstrings with deprecation notices.
src/kai_client/models.py Adds new response/settings/tool/suggestion models to parse kai-agent backend responses.
src/kai_client/__init__.py Exports the new models from the package public API.
tests/test_client.py Adds tests validating new endpoints, payload serialization, auth headers, and error handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/kai_client/client.py
Comment thread src/kai_client/client.py
Comment thread src/kai_client/client.py Outdated
Connects the client to the new kai-agent backend by adding methods for
all new endpoints and replacing the v6 approval protocol with the
dedicated POST /api/chat/{id}/approval side-channel.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Matovidlo Matovidlo force-pushed the feat/kai-agent-backend-integration branch from 4080d51 to b2bf2fe Compare May 11, 2026 08:25
kai-agent sends output: "denied" (string) when a tool approval is
rejected; the previous dict-only type caused a pydantic ValidationError.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Matovidlo Matovidlo requested a review from jordanrburger May 12, 2026 05:39
@Matovidlo Matovidlo marked this pull request as ready for review May 12, 2026 05:39
@jordanrburger jordanrburger merged commit 71ec42d into main May 12, 2026
3 checks 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.

3 participants