Skip to content

Fix/max tokens hardcoded#364

Merged
lukasdotcom merged 6 commits into
nextcloud:mainfrom
n-iv:fix/max-tokens-hardcoded
May 11, 2026
Merged

Fix/max tokens hardcoded#364
lukasdotcom merged 6 commits into
nextcloud:mainfrom
n-iv:fix/max-tokens-hardcoded

Conversation

@n-iv
Copy link
Copy Markdown
Contributor

@n-iv n-iv commented May 7, 2026

We noticed some occurrences of 'max_tokens' => 1000 in the Nextcloud codebase, specifically in:

  • apps/integration_openai/lib/TaskProcessing/TextToTextProvider.php
  • apps/integration_openai/lib/TaskProcessing/HeadlineProvider.php
  • apps/integration_openai/lib/TaskProcessing/TopicsProvider.php

This prevents requests from being executed in full, and leads to half-generated documents or truncated answers, which ruins the user experience.

We replaced those faulty lines with:
'max_tokens' => $this->openAiSettingsService->getMaxTokens()

n-iv added 3 commits May 7, 2026 10:31
Signed-off-by: Nicolas Varlot nicolas.varlot@ac-versailles.fr

Signed-off-by: Nicolas Varlot <165952530+n-iv@users.noreply.github.com>
Signed-off-by: Nicolas Varlot <165952530+n-iv@users.noreply.github.com>
Signed-off-by: Nicolas Varlot <165952530+n-iv@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 7, 2026 08:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes hardcoded max_tokens => 1000 defaults in the task-processing providers and instead uses the configured value from OpenAiSettingsService, preventing truncated generations when admins have configured higher token limits.

Changes:

  • Replaced hardcoded max_tokens defaults with $this->openAiSettingsService->getMaxTokens() in task optional input defaults.
  • Applies the same configuration-driven behavior consistently across headline, topics, and general text-to-text providers.

Reviewed changes

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

File Description
lib/TaskProcessing/TopicsProvider.php Use configured max token limit for default optional input shape.
lib/TaskProcessing/TextToTextProvider.php Use configured max token limit for default optional input shape.
lib/TaskProcessing/HeadlineProvider.php Use configured max token limit for default optional input shape.

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

@marinofaggiana marinofaggiana requested a review from julien-nc May 7, 2026 10:05
Copy link
Copy Markdown
Member

@lukasdotcom lukasdotcom left a comment

Choose a reason for hiding this comment

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

Thanks for the catch.

Comment thread lib/TaskProcessing/HeadlineProvider.php Outdated
n-iv and others added 3 commits May 8, 2026 23:52
Co-authored-by: Lukas Schaefer <lukas@lschaefer.xyz>
Signed-off-by: Nicolas Varlot <nicolas.varlot@ac-versailles.fr>
@lukasdotcom lukasdotcom merged commit 489d9a0 into nextcloud:main May 11, 2026
28 checks passed
@lukasdotcom
Copy link
Copy Markdown
Member

Thank you for your contribution @n-iv

@lukasdotcom lukasdotcom mentioned this pull request May 21, 2026
@github-actions
Copy link
Copy Markdown

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants