Skip to content

fix: DeduplicateLeversTask — per-lever decomposition, growing conversation, compact fallback - #203

Merged
neoneye merged 1 commit into
PlanExeOrg:mainfrom
VoynichLabs:fix/dedup-levers-v2-clean
Mar 8, 2026
Merged

neoneye merged 1 commit into
PlanExeOrg:mainfrom
VoynichLabs:fix/dedup-levers-v2-clean

Conversation

@82deutschmark

Copy link
Copy Markdown
Collaborator

Replaces #198 and #202. Single commit f02f1739 on top of current upstream/main — no conflicts. 1 file.

What changed

  • Per-lever decomposition: one LeverClassificationDecision call per lever (small-model compatible — no UUID reproduction required)
  • Growing conversation (option A): model sees all prior decisions when classifying each lever, enabling coherent absorb judgments
  • Compact-history fallback (option C): on failure, compresses prior decisions into a summary block and retries once
  • metadata: List[Dict[str, Any]] — accumulates all per-lever execute() call metadata (no overwrite)
  • No nonlocal, no nested try/except, no retry loop (llm_executor owns retries)
  • Two flat sequential try/except blocks: call → fail → compact → call once more → warn + default keep

Why

GLM 4.7 Flash returns HTTP 400 when full DeduplicationAnalysis schema sent (requires reproducing lever_id UUIDs). Per-lever calls with minimal schema work on all tested models.

…ibility

Replace monolithic DeduplicationAnalysis schema (requires LLM to output all
lever_ids) with per-lever decomposition using a minimal LeverClassificationDecision
schema (classification + justification only).

Changes:
- Module-level _build_compact_history() for option C context compaction
- Conversation grows per-lever (option A): SYSTEM -> USER(lever1) -> ASSISTANT -> ...
- Context folded into system message to avoid USER->USER before first ASSISTANT
- Two sequential try/except blocks (no nesting): first attempt with full history,
  second attempt (if needed) with compacted history
- llm_executor owns retry/fallback; task file owns compact-history fallback only
- IDs assigned by code; LLM never sees lever_id in schema
- Module-level constants and helpers (no closures)
@neoneye
neoneye merged commit cd5bb41 into PlanExeOrg:main Mar 8, 2026
3 checks passed
@neoneye
neoneye deleted the fix/dedup-levers-v2-clean branch March 8, 2026 13:41
neoneye added a commit that referenced this pull request Mar 8, 2026
- Fix broken USER→ASSISTANT alternation when default keep is used
- Extract closure to module-level _call_llm with functools.partial
- Use dict lookup for decisions instead of O(n²) loop
- Remove redundant DeduplicationAnalysis wrapper class
- Remove stale PROBLEM docstring (already fixed in PR #203)
- Rename reused `decision` variable to `lever_decision` in output loop

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
neoneye added a commit that referenced this pull request Mar 8, 2026
…-cleanup

fix: clean up deduplicate_levers.py — post PR #203 review fixes
neoneye added a commit that referenced this pull request Mar 8, 2026
* main:
  fix: replace functools.partial with closure for LLMExecutor compatibility
  fix: clean up deduplicate_levers.py — post PR #203 review fixes
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.

2 participants