ModelEngine-Group / ModelEngine-Group/nexent
Question: what's the intended lifecycle for `AgentRunManager._conversation_run_counts`?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.9k
- Forks
- 731
- Avg merge
- 19h 34m
- Merged PRs (30d)
- 172
Description
Looking at backend/agents/agent_run_manager.py, I'm puzzled by the bookkeeping around _conversation_run_counts. It's incremented in register_agent_run (line 43) and decremented in unregister_agent_run (lines 54-56), but then it's only read inside clear_conversation_context_manager (line 100) via pop, where the value is discarded entirely:
def clear_conversation_context_manager(self, conversation_id: Union[int, str]):
"""Explicitly clear the ContextManager for a conversation."""
conv_key = str(conversation_id)
with self._lock:
cm = self._conversation_context_managers.pop(conv_key, None)
self._conversation_run_counts.pop(conv_key, None)
if cm:
logger.info(...)
Two related questions:
-
Is
_conversation_run_countsmeant to gate auto-cleanup? I'd expect something like "when the count hits zero, also clear theContextManagerso a long-lived process doesn't leak per-conversation memory" — but no such logic exists. As written, the counter is updated but otherwise dead. -
If the counter is meant to be eventual / informational, why hold the lock to decrement it? Compare with
get_agent_run_info(line 65) which readsself.agent_runswithout the lock — so the class is already mixing locked-write/unlocked-read patterns and the counter's contribution is unclear.
A grep over backend/ and sdk/ shows no other reads of _conversation_run_counts. Either this is genuinely vestigial (in which case it can be deleted) or there's an intended behaviour that was never wired up (in which case it should be).
Happy to send a PR either way — just want to confirm intent before nuking it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with backend/agents/agent_run_manager.py, especially register_agent_run, unregister_agent_run, clear_conversation_context_manager, and get_agent_run_info. Confirm the grep result across backend/ and sdk/ and trace how conversation context managers are used. Done requires an agreed lifecycle for _conversation_run_counts, reflected in the implementation and relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100