Repository navigation
Conversation
|
Besides OpenCode Go, are there any other services that might be able to take advantage of or require this? Perhaps it would be safer to limit which headers can be sent, or do you think this approach is still fine? |
kyteinsky
left a comment
There was a problem hiding this comment.
maybe Summary, Translate, etc. tasks also need the conversation id injection since they use the same chat completion endpoint.
for opencode, they wouldn't work without the conversation id header.
| return header.name !== header.name.trim() | ||
| || header.value !== header.value.trim() |
There was a problem hiding this comment.
not sure if this works well for UX, if there is a genuine space after the header name/value, it will not be registered, maybe we can still register it trimmed?
if new edits to the field land, a new request can be made to save that.
wdyt?
There was a problem hiding this comment.
Trimmed values are saved now.
| || this.headerNameInvalid(header.name) | ||
| || this.headerValueInvalid(header.value) |
There was a problem hiding this comment.
it might be good to show an error/red the input box if these fail so the user is aware there is a mistake
There was a problem hiding this comment.
ah this is already the case, maybe dirty header can be replaced with a debounce?
There was a problem hiding this comment.
Could you give more details on your suggestion?
| $name = trim($header['name']); | ||
| if ($name !== '' && preg_match(ServiceConfig::HEADER_NAME_PATTERN, $name) !== 1) { |
There was a problem hiding this comment.
maybe empty header names can be rejected here too
There was a problem hiding this comment.
Empty header names and values cannot be saved now.
| /** Characters an HTTP header name is made of (the RFC 7230 token) */ | ||
| public const HEADER_NAME_PATTERN = '/^[a-zA-Z0-9!#$%&\'*+.^_`|~-]+$/'; |
There was a problem hiding this comment.
perhaps the regex can be aligned with that of guzzle, especially the FIELD_VALUE_PATTERN one
https://github.com/guzzle/psr7/blob/a3059ba1a84c9139c4ae03cf0f45bea276c97c74/src/Rfc9110.php
https://github.com/guzzle/psr7/blob/a3059ba1a84c9139c4ae03cf0f45bea276c97c74/src/MessageTrait.php
| 'body' => $body, | ||
| 'content-type' => $contentTypeHeader, | ||
| ]; | ||
| } catch (ClientException|ServerException $e) { |
There was a problem hiding this comment.
\InvalidArgumentException can be thrown in the request too if headers are not valid, would be nice to catch them too here.
see the header regex link.
There was a problem hiding this comment.
Done. It is useful indeed. Some header values could be revealed to the users.
2ccc1d0 to
66b452f
Compare
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
…tion ID passed as an optional input field in the chat providers Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
…tion providers
The {$conversation_id} extra header was only expanded for the chat
providers. Summary, translate and all the other task types that go
through the chat completion endpoint are as well concerned: services
requiring that header reject their requests without it.
Every provider reaching the chat completion endpoint now takes an
optional conversation_id input and passes it along the completion
request. The providers delegating to another one (enhanced audio to
text, improved prompt image generation) forward it, and the translation
service gained a conversation ID parameter.
Assisted-by: OpenCode:qwen3.8-flash
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
… one The assistant generic form schedules tasks through the task processing endpoints directly, so it cannot pass the optional conversation ID input. Services requiring the conversation header then rejected the requests. Chat completion requests now always carry a conversation ID: a random throwaway one is generated when the task does not belong to a conversation, refreshed per request so unrelated tasks never share state on conversation-aware services. Non-chat endpoints keep dropping such a header. Assisted-by: OpenCode:qwen3.8-flash Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
66b452f to
501efdc
Compare
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
I think it's fine to let the admin set any extra headers. It makes it more generic. Some services might have some exotic authentication based on specific headers. |
closes #436
refs #430
Some services might require extra headers like a non-standard authentication header.
{$conversation_id) in the header value. This variable is only resolved in chat providers. It resolves to theconversation_idoptional input that is sent by the assistant (see Let the chat providers know about the conversation/session ID assistant#674 ). This header will only be sent for chat requests.🤖 AI (if applicable)