The author might be a bit busy and unable to address these features for now.
In my own experience, using the chat endpoint tends to get more refusals to reply, whereas using the message endpoint delivers answers and tool calls more reliably. Occasionally, refusals or repeating still happen — in those cases, try adjusting the “thinking level” setting and it should help.
The main issue I actually wanted to solve was this: I previously used it once and noticed that tool calls were limited to 16 rounds. Then when I tried it again today, I was forced to reset my password, but the reset interface didn’t pop up, so I couldn’t use any of the features at all. That’s why I created this fork, intending it as a temporary tool. It logs only for up to 2 hours, and any logs beyond that period won’t be recorded anymore.
# Changelog
## 2026-08-14 (b61c76a → bff8088)
### Added
-
Usage Log Retention and Trimming: Added
M365_USAGE_RETENTION_HOURSenvironment variable. Usage records are automatically trimmed by time window (default 2 hours; set to 0 to disable time-based trimming, retaining logs only by entry count). -
Optimized Usage Log Storage: Changed from append-only to atomic file rewrite, preventing
usage.jsonlfrom growing indefinitely. Old files with too much data will be marked as dirty and compressed during the first rewrite after startup. -
Linked Deletion Cleanup: When deleting an API Key, all usage history corresponding to its prefix is now cleaned up simultaneously (
purgePrefix). -
Unified Token Estimation: Added
countTokens(forgpt-*models uses offline tiktoken, others use character-based heuristics).CacheStatsand all usage endpoints now use the same estimator. -
Cache Hit Reporting: OpenAI
/v1/chat/completionsnow reportsprompt_tokens_details.cached_tokens;/v1/responsesreportscache_read_input_tokens; cached tokens are included for historical messages. -
Anthropic Usage Fix:
/v1/messagesnow shows locally estimatedinput_tokens/output_tokensinstead of always 0, and separates them per SSE spec (message_startfor input,message_deltafor output). -
Avoid Duplicate Counting: Adapter now marks reused paths to skip additional usage records; Responses / Anthropic API calls no longer trigger duplicate recording in
/v1/chat/completions. -
Test Coverage: Added unit tests for usage retention/trimming/deletion linkage, and a
scripts/test_api.pyscript to verify batch endpoint usage.
### Fixed
-
keys.go: Fixed indentation and curly brace nesting for rollback blocks when savingcreatefails. -
server.go: AlignedoaiReqstruct fields with M365 metadata format. -
Removed leftover merge conflict markers from
account_health_test.goand fixed TMPDIR contamination inauto_cleanup_test.go.
### Build and Repository
-
Included
m365-copilot2api.exe(Windows executable) in version control for easy direct distribution. -
Added
M365-Copilot2API.code-workspacefor workspace configuration. -
Updated
.gitignoreto include rules to ignore.zcodedirectory.



