Skip to content

[P2][Code Quality] Extract magic constants to configuration #16

@aWN4Y25pa2EK

Description

@aWN4Y25pa2EK

Summary

Numerous hard-coded values scattered throughout the codebase make configuration and tuning difficult.

Source

Code Reviewer Assessment

Locations

  • impl/mvp/src/holons/root.ts:427-428 - ESTIMATED_TOKENS_PER_AGENT_CALL = 5000
  • impl/mvp/src/holons/root.ts:429 - CONFIDENCE_THRESHOLD = 0.6
  • impl/mvp/src/holons/root.ts:441 - retry calculations
  • impl/mvp/src/config.ts:87,90,163-165 - model defaults, URLs
  • impl/mvp/src/holons/adk/runner.ts:199 - DEFAULT_AGENT_TIMEOUT_MS = 120_000

Examples

// Scattered throughout root.ts
const BUDGET_TOKENS = task.constraints.budget.tokens;
const ESTIMATED_TOKENS_PER_AGENT_CALL = 5000;
const CONFIDENCE_THRESHOLD = 0.6;

Impact

  • Hard to tune system behavior
  • Values not documented
  • Different environments need different values
  • Testing requires code changes

Severity

Medium | Likelihood: High (affects every deployment)

Recommended Fix

Create dedicated constants file and config schema:

// src/constants.ts
export const LLM_CONSTANTS = {
  CONFIDENCE_THRESHOLD: 0.6,
  TOKENS_PER_AGENT_CALL_ESTIMATE: 5000,
  DEFAULT_TIMEOUT_MS: 120_000,
  MAX_SUBTASKS: 50,
  MAX_CRITERIA: 20,
} as const;

// Or add to config schema
const HolonConfigSchema = z.object({
  confidenceThreshold: z.number().min(0).max(1).default(0.6),
  tokensPerAgentEstimate: z.number().int().default(5000),
  agentTimeoutMs: z.number().int().default(120_000),
});

Generated by HCA Architecture Assessment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions