fix(agent): dynamic data-source count and gate microcompact by token …#296
fix(agent): dynamic data-source count and gate microcompact by token …#296MarkfuGod wants to merge 2 commits into
Conversation
…pressure Stop the system prompt from advertising a stale "7 data sources" after the 0.1.10 loader expansion by deriving the count from VALID_SOURCES. Only run Layer-1 microcompact once the transcript exceeds half of TOKEN_THRESHOLD so short runs keep earlier tool results instead of clearing them every iteration. Signed-off-by: MarkfuGod <MarkfuGod@outlook.com>
|
Thanks @MarkfuGod — I read through the diff and the code is exactly right: One thing blocks merge, and it's the part I specifically asked for on the issue — the regression tests aren't in the diff. Your PR description lists three ("data-source count derivation", "import-failure fallback path", " Since this is in the protected
Add those (your |
|
Thanks, fixed. @warren618 Added the requested regression tests:
Targeted tests are green:
# IN test_lookahead.py
Lines 162-166
except RegistryError as exc:
# >95% NaN cascade from compounding rolling operators on a
# synthetic random panel is a known artifact, distinct from
# look-ahead leakage. Bench on real market data won't trip it.
pytest.skip(f"{alpha_id}: registry sanity check on synthetic panel ({exc})") |
📝 Description
This PR addresses two
src/agent/issues identified in #282 following the v0.1.10 data-layer expansion. It has been approved for implementation by @warren618.Changes Included:
7data sources incontext.pywith a dynamic derivation frombacktest.loaders.registry.VALID_SOURCES - {"auto"}. Implemented an import-safe fallback mechanism to ensure prompt assembly/startup never breaks if the registry import fails._microcompact()Execution: AddedMICROCOMPACT_THRESHOLD = int(TOKEN_THRESHOLD * 0.5)inloop.py._microcompact()now only executes when the estimated transcript size exceeds this threshold, preserving older tool results during short, low-pressure runs.🎯 Scope Check
🧪 Validation & Regression Tests
1. New Regression Tests Added
_microcompact()behavior (no-op below threshold, fires correctly above threshold).2. Local Test Execution
pytest tests/test_loop_helpers.py tests/test_context_attribution_layers.py -qpytest --ignore=agent/tests/e2e_backtest -qFixes #282
CC: @warren618