Skip to content

feat: add AUTO_TAG_COMPLETE environment variable#892

Open
cfilipov wants to merge 3 commits into
icereed:mainfrom
cfilipov:feat/auto-tag-complete
Open

feat: add AUTO_TAG_COMPLETE environment variable#892
cfilipov wants to merge 3 commits into
icereed:mainfrom
cfilipov:feat/auto-tag-complete

Conversation

@cfilipov

@cfilipov cfilipov commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Add AUTO_TAG_COMPLETE environment variable to tag documents after auto-processing is complete, similar to PDF_OCR_COMPLETE_TAG for OCR processing.

Default value: paperless-gpt-auto-complete

Summary by CodeRabbit

  • New Features

    • AUTO_TAG_COMPLETE env var adds a tag to documents after automatic processing (not applied during manual review). Set to empty to disable; when unset a default tag is used.
  • Documentation

    • README updated with AUTO_TAG_COMPLETE description and configuration guidance.

Add AUTO_TAG_COMPLETE environment variable to tag documents after
auto-processing is complete, similar to PDF_OCR_COMPLETE_TAG for OCR
processing.

Default value: paperless-gpt-auto-complete
@coderabbitai

coderabbitai Bot commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Adds an AUTO_TAG_COMPLETE env var, threads its value into App, marks auto-processing requests with IsAutoProcessing, and appends the configured completion tag to suggestion AddTags during automatic processing.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added AUTO_TAG_COMPLETE environment variable and description to the env table.
Configuration / App init
main.go
Introduced global autoTagComplete (read from AUTO_TAG_COMPLETE, default paperless-gpt-auto-complete), added autoTagComplete field to App and wired it into initialization and env validation.
Tagging logic
app_llm.go
When IsAutoProcessing is true and autoTagComplete is non-empty, append autoTagComplete to DocumentSuggestion.AddTags and emit a debug log.
Background / Request flag
background.go, types.go
Set IsAutoProcessing = true on GenerateSuggestionsRequest during auto-processing; added internal-only IsAutoProcessing bool \json:"-"`toGenerateSuggestionsRequest`.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

safe-to-test

Poem

🐇 I hopped through envs and left a tiny sign,
A tag for each doc where auto-works align,
Threaded in App, a neat little feat,
I nudge AddTags on paws so sweet,
Carrots for code — hooray, that’s fine!

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (12 files):

⚔️ README.md (content)
⚔️ app_http_handlers.go (content)
⚔️ app_llm.go (content)
⚔️ app_llm_test.go (content)
⚔️ background.go (content)
⚔️ background_test.go (content)
⚔️ main.go (content)
⚔️ ocr/llm_provider.go (content)
⚔️ ocr/provider.go (content)
⚔️ paperless.go (content)
⚔️ paperless_test.go (content)
⚔️ types.go (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding the AUTO_TAG_COMPLETE environment variable. It is specific, clear, and directly related to the primary objective of the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch feat/auto-tag-complete
  • Post resolved changes as copyable diffs in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@app_llm.go`:
- Around line 674-678: generateDocumentSuggestions currently applies
app.autoTagComplete unconditionally, causing manually-reviewed docs to get the
"auto-processing complete" tag; change generateDocumentSuggestions signature to
accept a boolean flag like isAuto (or source enum) and only append
app.autoTagComplete when isAuto is true, then update both callers (the manual
review caller and the auto-processing caller) to pass false and true
respectively; ensure the parameter name and the variable app.autoTagComplete are
used so the conditional lives inside generateDocumentSuggestions and no other
behavior is changed.

In `@main.go`:
- Around line 564-566: The auto-complete tag defaulting makes disabling
impossible because validateOrDefaultEnvVars unconditionally fills
autoTagComplete, yet app_llm.go gates on app.autoTagComplete != ""; fix by
either adding a boolean env like AUTO_TAG_COMPLETE_ENABLED (mirror
PDF_OCR_TAGGING and pdfOCRCompleteTag flow) and use it to control whether the
tag is appended, or change logic to treat an explicit empty env as “disabled” by
reading the env with os.LookupEnv in validateOrDefaultEnvVars (or set
autoTagComplete there) so you only default when the env is truly unset; update
the check in app_llm.go to rely on the new boolean or the possibly-empty
app.autoTagComplete accordingly.

In `@README.md`:
- Line 544: Update the README entry for AUTO_TAG_COMPLETE to document how users
can disable auto-completion tagging: state the exact environment variable
behavior (e.g., set AUTO_TAG_COMPLETE="" to disable or unset it) and mention the
alternative disable mechanism implemented in main.go (reference the logic in
main.go that reads AUTO_TAG_COMPLETE or the new enable flag name if added), and
include a short example showing disabling via environment variable and via the
enable flag if present so users know the opt-out path.

Comment thread app_llm.go Outdated
Comment thread main.go Outdated
Comment thread README.md Outdated
…abling

The autoTagComplete tag was unconditionally added in generateDocumentSuggestions,
which meant documents processed via manual review also received it. Additionally,
validateOrDefaultEnvVars always defaulted the tag, making it impossible to disable.

- Add IsAutoProcessing field to GenerateSuggestionsRequest to distinguish flows
- Set IsAutoProcessing=true only in the background auto-processing caller
- Gate auto-complete tag on both non-empty value and IsAutoProcessing flag
- Use os.LookupEnv so AUTO_TAG_COMPLETE="" explicitly disables the feature
- Update README to document the disable mechanism

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
main.go (1)

564-568: Consider logging the resolved autoTagComplete value for consistency.

Other tags like manualTag and autoTag are logged via fmt.Printf after defaulting (lines 545, 550). Adding a similar log for autoTagComplete would help with debugging.

Suggested addition
 	if val, ok := os.LookupEnv("AUTO_TAG_COMPLETE"); ok {
 		autoTagComplete = val
 	} else {
 		autoTagComplete = "paperless-gpt-auto-complete"
 	}
+	if autoTagComplete != "" {
+		fmt.Printf("Using %s as auto tag complete\n", autoTagComplete)
+	} else {
+		fmt.Println("Auto tag complete is disabled")
+	}

@cfilipov

cfilipov commented Feb 16, 2026

Copy link
Copy Markdown
Contributor Author

🧹 Nitpick comments (1)

main.go (1)> 564-568: Consider logging the resolved autoTagComplete value for consistency.

Other tags like manualTag and autoTag are logged via fmt.Printf after defaulting (lines 545, 550). Adding a similar log for autoTagComplete would help with debugging.

Suggested addition

 	if val, ok := os.LookupEnv("AUTO_TAG_COMPLETE"); ok {
 		autoTagComplete = val
 	} else {
 		autoTagComplete = "paperless-gpt-auto-complete"
 	}
+	if autoTagComplete != "" {
+		fmt.Printf("Using %s as auto tag complete\n", autoTagComplete)
+	} else {
+		fmt.Println("Auto tag complete is disabled")
+	}

This new tag is already being logged in app_llm.go
Edit: ah nvm I misunderstood what this was asking for, will update.

Match the existing logging pattern used by manualTag and autoTag.
@cfilipov

Copy link
Copy Markdown
Contributor Author

I see there is a CI failure, but it doesnt look like its related to my changes as far as I can tell.

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.

1 participant