feat(dgw): add an AI client crate for session action descriptions - #2005
Draft
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 2 commits into
Draft
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 2 commits into
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 2 commits into
Conversation
This was referenced Sep 26, 2026
irvingouj@Devolutions (irvingoujAtDevolution)
force-pushed
the
chore/reqwest-0.13
branch
from
September 28, 2026 20:33
035c31d to
6dbda85
Compare
irvingouj@Devolutions (irvingoujAtDevolution)
force-pushed
the
feat/ai-crate
branch
from
September 28, 2026 20:33
cc6204e to
cdf5901
Compare
irvingouj@Devolutions (irvingoujAtDevolution)
force-pushed
the
chore/reqwest-0.13
branch
from
September 29, 2026 20:14
6dbda85 to
3d90e1e
Compare
irvingouj@Devolutions (irvingoujAtDevolution)
force-pushed
the
feat/ai-crate
branch
2 times, most recently
from
September 30, 2026 03:01
6b803b0 to
5d955a5
Compare
irvingouj@Devolutions (irvingoujAtDevolution)
changed the base branch from
chore/reqwest-0.13
to
feat/jrec-manifest-logs
September 30, 2026 03:01
irvingouj@Devolutions (irvingoujAtDevolution)
force-pushed
the
feat/ai-crate
branch
2 times, most recently
from
September 30, 2026 18:07
16265bd to
6ebc3bc
Compare
| @@ -0,0 +1,699 @@ | |||
| //! Purpose-level AI helpers for Devolutions Gateway. | |||
There was a problem hiding this comment.
Can you explain what is the meaning of "purpose-level" in this context?
Comment on lines
+48
to
+49
| pub enum Provider { | ||
| /// OpenAI chat completions; the default base URL is `https://api.openai.com/v1/`. |
There was a problem hiding this comment.
I think I appreciate the fact that our vendored implementation is small and self-contained, but could you also elaborate why not using a crate such as llm, which could support much more providers?
`devolutions-gateway-ai` asks a model which actions a user performed in a session transcript and parses its JSON Lines answer into typed actions. It talks to the providers' HTTP APIs directly, with the workspace reqwest client passed by the caller (so Gateway's proxy and TLS policy apply): OpenAI chat completions (OpenAI, Mistral, any OpenAI-compatible endpoint) and Anthropic Messages. Only the fields of a single text completion are modeled, so there is no AI framework dependency and no new crate in the lockfile. The API key is redacted from every error. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The crate had one purpose, and its shared parts were shaped by it: one prompt version for the whole crate, a purpose-specific error next to the transport ones, and retry rules left to every caller. Upcoming AI tasks need the same client with other prompts. Each purpose is now a module owning its prompt, prompt version and parser, and adding a method to AiClient; session_actions is the first. The provider formats live under wire/. Every purpose returns a Response with the output, the model reported by the provider and the token usage, which later budget and audit work needs. Error tells whether a request is worth retrying, reports answers cut at the output token limit as Truncated, and treats unusable model text as InvalidOutput. The builder rejects API keys that are not valid header values and base URLs that are not HTTP, so sending never fails on settings.
irvingouj@Devolutions (irvingoujAtDevolution)
force-pushed
the
feat/ai-crate
branch
from
September 30, 2026 23:27
6ebc3bc to
017745d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
devolutions-gateway-ai, a small crate Gateway uses to ask an AI provider what a user did in a session.It calls the providers' HTTP APIs directly with the caller's reqwest client (so Gateway's proxy and TLS policy apply), no AI framework and no new crate in
Cargo.lock:The prompt lives in the crate (
PROMPT_VERSION), the key is aSecretStringand gets redacted from errors, error reasons never quote the answer. Nothing calls it yet; the first caller is #2008.Tested: crate tests 12/12, mock-provider HTTP tests (
gateway_ai) 11/11 (paths, auth headers, token fields, error redaction).Stacked on #2003.
🤖 Generated with Claude Code