Skip to content

fix(compact): validate compact_threshold is at least 1000 (#838) - #889

Queued
Artemon-line wants to merge 3 commits into
praxis-proxy:mainfrom
Artemon-line:838-compaction-accepts-compact_threshold-values-below-the-openai-minimum
Queued

fix(compact): validate compact_threshold is at least 1000 (#838)#889
Artemon-line wants to merge 3 commits into
praxis-proxy:mainfrom
Artemon-line:838-compaction-accepts-compact_threshold-values-below-the-openai-minimum

Conversation

@Artemon-line

Copy link
Copy Markdown
Contributor

Summary

Validate compact_threshold as at least 1000 when parsing the compaction entry in context_management. Invalid or missing proxy-consumed values produce an invalid_request_error rather than silently skipping or executing compaction.

Related issue

Closes #838

Validation

  • Unit tests (cargo test -p praxis-ai-apis -- compact)
  • Integration or functional tests (cargo test -p praxis-tests-integration -- compact)
  • make lint

Verification Proof

To test the rejection for an invalid threshold (< 1000), send a value below 1000 (e.g. 50):

curl -i -X POST http://localhost:8080/v1/responses \
  -H "Content-Type: application/json" \
  -d '{"model":"llama3.2:1b","input":"Hello","context_management":[{"type":"compaction","compact_threshold":50}]}'

The proxy will intercept it and return HTTP 400 Bad Request directly:

HTTP/1.1 400 Bad Request
Content-Type: application/json

{"error":{"code":"invalid_request_error","message":"compact_threshold must be an integer of at least 1000","param":null,"type":"invalid_request_error"}}

Checklist

  • I reviewed every changed line and can explain the change.
  • New capabilities include an example config and functional example test.
  • User-facing behavior and generated documentation are updated.
  • Performance-sensitive changes include appropriate benchmark or load-test evidence.
  • Commits are signed and include a Signed-off-by trailer.

Breaking changes

None.

@Artemon-line
Artemon-line force-pushed the 838-compaction-accepts-compact_threshold-values-below-the-openai-minimum branch from eaadc66 to 61f001e Compare September 2, 2026 12:54
…xy#838)

Validate that  in  compaction
entries is an integer of at least 1000 tokens. Invalid or missing
threshold values now return a 400  response
instead of silently skipping or executing compaction.

Fixes praxis-proxy#838

Signed-off-by: Artemy <ahladenk@redhat.com>
@Artemon-line
Artemon-line force-pushed the 838-compaction-accepts-compact_threshold-values-below-the-openai-minimum branch from 61f001e to dc2e02c Compare September 2, 2026 14:58
@Artemon-line
Artemon-line marked this pull request as ready for review September 2, 2026 15:41
@Artemon-line
Artemon-line requested review from a team, alexsnaps and leseb September 2, 2026 15:41
@leseb leseb added the praxis-known-issue Allow `test-praxis-main` to continue on error; Use for known / transient compatibility issues label Sep 2, 2026

@praxis-bot praxis-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PR Review

Summary: Validates compact_threshold as at least 1000, converting extract_compaction_config and should_compact to return Result so invalid values produce invalid_request_error instead of being silently skipped. Clean refactor with good test coverage for threshold edge cases.

Overall: The validation logic, error messaging, and integration test are solid. One new validation path lacks test coverage.

Severity Count
Critical 0
Large 0
Medium 1

Comment thread apis/src/openai/responses/compact/mod.rs
@leseb
leseb enabled auto-merge September 3, 2026 12:18
@leseb
leseb added this pull request to the merge queue Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

praxis-known-issue Allow `test-praxis-main` to continue on error; Use for known / transient compatibility issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compaction accepts compact_threshold values below the OpenAI minimum

3 participants