From 630db02cd32c7fbeb6e0a8fdb49485391ce11a74 Mon Sep 17 00:00:00 2001 From: adavyas Date: Thu, 23 Apr 2026 15:59:20 -0700 Subject: [PATCH] chore: lower deriver custom instruction cap --- README.md | 2 +- config.toml.example | 2 +- docs/v3/contributing/configuration.mdx | 2 +- src/config.py | 2 +- tests/test_config.py | 16 ++++++++++++---- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ffb419fa..81af98ad 100644 --- a/README.md +++ b/README.md @@ -428,7 +428,7 @@ Examples: - `DB_CONNECTION_URI` - Database connection string - `AUTH_JWT_SECRET` - JWT secret key - `DERIVER_MODEL_CONFIG__TRANSPORT` - Transport for the background deriver -- `DERIVER_MAX_CUSTOM_INSTRUCTIONS_TOKENS` - Explicit prompt budget cap for deriver custom instructions +- `DERIVER_MAX_CUSTOM_INSTRUCTIONS_TOKENS` - Explicit prompt budget cap for deriver custom instructions (maximum supported value: `500`) - `SUMMARY_MODEL_CONFIG__MODEL` - Summary model override - `DIALECTIC_LEVELS__low__MODEL_CONFIG__MODEL` - Model for low reasoning level - `LOG_LEVEL` - Application log level diff --git a/config.toml.example b/config.toml.example index affc0392..d63b0de3 100644 --- a/config.toml.example +++ b/config.toml.example @@ -86,7 +86,7 @@ STALE_SESSION_TIMEOUT_MINUTES = 5 DEDUPLICATE = true LOG_OBSERVATIONS = false MAX_INPUT_TOKENS = 23000 -MAX_CUSTOM_INSTRUCTIONS_TOKENS = 1024 # Required for non-blank reasoning.custom_instructions; over-limit values fail validation +MAX_CUSTOM_INSTRUCTIONS_TOKENS = 500 # Required for non-blank reasoning.custom_instructions; max supported value is 500 WORKING_REPRESENTATION_MAX_OBSERVATIONS = 100 REPRESENTATION_BATCH_MAX_TOKENS = 1024 FLUSH_ENABLED = false # Bypass batch token threshold, process work immediately diff --git a/docs/v3/contributing/configuration.mdx b/docs/v3/contributing/configuration.mdx index 3fc72eb9..7eb26dee 100644 --- a/docs/v3/contributing/configuration.mdx +++ b/docs/v3/contributing/configuration.mdx @@ -532,7 +532,7 @@ DEFAULT_TTL_SECONDS = 300 [deriver] ENABLED = true WORKERS = 1 -MAX_CUSTOM_INSTRUCTIONS_TOKENS = 1024 +MAX_CUSTOM_INSTRUCTIONS_TOKENS = 500 [deriver.model_config] transport = "openai" diff --git a/src/config.py b/src/config.py index fa647031..39e38ac0 100644 --- a/src/config.py +++ b/src/config.py @@ -733,7 +733,7 @@ class DeriverSettings(HonchoSettings): MAX_INPUT_TOKENS: Annotated[int, Field(default=23000, gt=0, le=23000)] = 23000 MAX_CUSTOM_INSTRUCTIONS_TOKENS: Annotated[ - int | None, Field(default=None, gt=0, le=23000) + int | None, Field(default=None, gt=0, le=500) ] = None # Maximum number of observations to return in working representation diff --git a/tests/test_config.py b/tests/test_config.py index cc3b9258..e6d2a46f 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -7,6 +7,7 @@ def _make_deriver_settings( *, MAX_INPUT_TOKENS: int = 23000, MAX_CUSTOM_INSTRUCTIONS_TOKENS: int | None = None, + REPRESENTATION_BATCH_MAX_TOKENS: int = 1024, ) -> DeriverSettings: return DeriverSettings( MODEL_CONFIG=ConfiguredModelSettings( @@ -15,6 +16,7 @@ def _make_deriver_settings( ), MAX_INPUT_TOKENS=MAX_INPUT_TOKENS, MAX_CUSTOM_INSTRUCTIONS_TOKENS=MAX_CUSTOM_INSTRUCTIONS_TOKENS, + REPRESENTATION_BATCH_MAX_TOKENS=REPRESENTATION_BATCH_MAX_TOKENS, ) @@ -29,9 +31,9 @@ def test_effective_custom_instructions_tokens_requires_explicit_limit() -> None: def test_effective_custom_instructions_tokens_uses_explicit_limit() -> None: - settings = _make_deriver_settings(MAX_CUSTOM_INSTRUCTIONS_TOKENS=2048) + settings = _make_deriver_settings(MAX_CUSTOM_INSTRUCTIONS_TOKENS=500) - assert settings.effective_max_custom_instructions_tokens == 2048 + assert settings.effective_max_custom_instructions_tokens == 500 def test_custom_instructions_tokens_cannot_exceed_input_budget() -> None: @@ -40,6 +42,12 @@ def test_custom_instructions_tokens_cannot_exceed_input_budget() -> None: match=r"MAX_CUSTOM_INSTRUCTIONS_TOKENS.*cannot exceed max deriver input tokens", ): _make_deriver_settings( - MAX_INPUT_TOKENS=1024, - MAX_CUSTOM_INSTRUCTIONS_TOKENS=2048, + MAX_INPUT_TOKENS=400, + MAX_CUSTOM_INSTRUCTIONS_TOKENS=500, + REPRESENTATION_BATCH_MAX_TOKENS=128, ) + + +def test_custom_instructions_tokens_cannot_exceed_supported_cap() -> None: + with pytest.raises(ValueError, match="less than or equal to 500"): + _make_deriver_settings(MAX_CUSTOM_INSTRUCTIONS_TOKENS=501)