Skip to content

Adjust huge token use - #46

Open
emf37 wants to merge 1 commit into
FrancescoStabile:mainfrom
emf37:main
Open

emf37 wants to merge 1 commit into
FrancescoStabile:mainfrom
emf37:main

Conversation

@emf37

@emf37 emf37 commented Aug 16, 2026

Copy link
Copy Markdown

Hi, numasec
after a penetration testing session, I found that numasec had used up 143M tokens (approximately $18), which is an unusually high amount for the DeepSeek V4 Flash model. Having analysed local logs and token usage, I implemented the following modifications. Subsequent testing showed that Numasec consumed just $0.28 while using 32.2M tokens.

snapshot.ts->renderContext():remove mtime field in prompt (generated_at、projection_lag_ms、source_context_mtime、stale_context、context_file_stale、audit_after_context) , filter warnings/next-actions pointing to active-context.md.

retry.ts-> add RETRY_MAX_ATTEMPTS = 5 to prevent unlimited retry, policy() will stop after retry 5 attempts.

instruction.ts-> system() will not concat context package, add context() to return rendered package.

prompt.ts -> main loop switch to call instruction.context() ,keep system prompt prefix is static, and the package is wrapped in <system-reminder> and injected at the end of messages.

snapshot.ts->renderContext():remove mtime field in prompt (generated_at、projection_lag_ms、source_context_mtime、stale_context、context_file_stale、audit_after_context) , filter warnings/next-actions pointing to active-context.md.
retry.ts-> add `RETRY_MAX_ATTEMPTS = 5` to prevent unlimited retry, `policy()`  will stop after retry 5 attempts.
instruction.ts-> `system()` will not concat context package, add `context()` to return rendered package.
prompt.ts -> main loop switch to call `instruction.context()`  ,keep system prompt prefix is static, and the package is wrapped in `<system-reminder>` and injected at the end of messages.
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.

1 participant