Problem or Motivation
I noticed two small agent-core issues after the v0.1.10 data-layer expansion, but since the PR template marks src/agent/ as a protected area, I wanted to open an issue first before submitting a PR.
- The agent system prompt still says it has
7 data sources, while the loader registry now exposes 18 concrete sources after v0.1.10. This can make the agent under-advertise its current data capabilities.
AgentLoop currently runs Layer-1 _microcompact() every iteration, even when the transcript is well below any token pressure threshold. That clears older tool results to [cleared] on short runs, which can remove useful metrics, file contents, or search results the model may still need to reference.
Proposed Solution
I prepared a small draft branch here for maintainer review before opening a PR:
https://github.com/MarkfuGod/Vibe-Trading/tree/fix/agent-prompt-and-microcompact-gating
The draft does two things:
- Derives
{data_source_count} from backtest.loaders.registry.VALID_SOURCES - {"auto"} instead of hardcoding 7, with a safe fallback so prompt building cannot break startup if registry import fails.
- Adds
MICROCOMPACT_THRESHOLD = int(TOKEN_THRESHOLD * 0.5) and only calls _microcompact() when the estimated transcript size exceeds that threshold. Layer escalation then becomes: microcompact at ~20k, context collapse at ~28k, auto-compact at ~40k by default.
Alternatives Considered
- Just update
7 to 18: simpler, but it will drift again when sources are added or removed.
- Increase
KEEP_RECENT: helps but still clears history every iteration, including short low-pressure runs.
- Move the fix into a larger context-management refactor: likely too broad for this small behavior correction.
Validation Done Locally
- Verified the dynamic count matches the registry:
data_source_count = 18
len(VALID_SOURCES - {"auto"}) = 18
- Targeted tests:
pytest tests/test_loop_helpers.py tests/test_context_attribution_layers.py -q -> 38 passed
- Additional agent/memory-related targeted set -> 120 passed
- Broader local suite had unrelated environment failures around FastAPI 204 response handling / SPA deep-link tests, so I did not treat those as caused by this draft.
Contribution
I'm willing to submit a PR if maintainers agree this is an acceptable direction for the protected src/agent/ area.
Problem or Motivation
I noticed two small agent-core issues after the v0.1.10 data-layer expansion, but since the PR template marks
src/agent/as a protected area, I wanted to open an issue first before submitting a PR.7 data sources, while the loader registry now exposes 18 concrete sources after v0.1.10. This can make the agent under-advertise its current data capabilities.AgentLoopcurrently runs Layer-1_microcompact()every iteration, even when the transcript is well below any token pressure threshold. That clears older tool results to[cleared]on short runs, which can remove useful metrics, file contents, or search results the model may still need to reference.Proposed Solution
I prepared a small draft branch here for maintainer review before opening a PR:
https://github.com/MarkfuGod/Vibe-Trading/tree/fix/agent-prompt-and-microcompact-gating
The draft does two things:
{data_source_count}frombacktest.loaders.registry.VALID_SOURCES - {"auto"}instead of hardcoding7, with a safe fallback so prompt building cannot break startup if registry import fails.MICROCOMPACT_THRESHOLD = int(TOKEN_THRESHOLD * 0.5)and only calls_microcompact()when the estimated transcript size exceeds that threshold. Layer escalation then becomes: microcompact at ~20k, context collapse at ~28k, auto-compact at ~40k by default.Alternatives Considered
7to18: simpler, but it will drift again when sources are added or removed.KEEP_RECENT: helps but still clears history every iteration, including short low-pressure runs.Validation Done Locally
data_source_count = 18len(VALID_SOURCES - {"auto"}) = 18pytest tests/test_loop_helpers.py tests/test_context_attribution_layers.py -q-> 38 passedContribution
I'm willing to submit a PR if maintainers agree this is an acceptable direction for the protected
src/agent/area.