Skip to content

Refactor usage constants into factory functions - #1137

Open
Pratham-ds wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
Pratham-ds:patch-1
Open

Refactor usage constants into factory functions#1137
Pratham-ds wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
Pratham-ds:patch-1

Conversation

@Pratham-ds

@Pratham-ds Pratham-ds commented Aug 10, 2026

Copy link
Copy Markdown

Refactor usage and model constants into factory functions in Agent

  • Replaces shared EMPTY_USAGE and DEFAULT_MODEL constants with createEmptyUsage() and createDefaultModel() factory functions so each caller gets a unique object instance, preventing shared-state mutations.
  • Agent.reset now throws if called while a run is active; callers must wait for idle before resetting.
  • Agent.finishRun clears activeRun before resolving the run promise, so isProcessing is false during resolution callbacks.
  • Agent.processEvents iterates over a snapshot of listeners, so subscribe/unsubscribe calls during dispatch take effect only on subsequent events.
  • Adds Agent.isProcessing getter that returns true when a run is active.
  • Behavioral Change: reset during an active run now throws instead of silently clearing state.

Macroscope summarized 2850a37.

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