Skip to content

feat: add environment-based agent weight system#6

Merged
Gaubee merged 2 commits intomainfrom
feat/agent-weight-system
Dec 19, 2025
Merged

feat: add environment-based agent weight system#6
Gaubee merged 2 commits intomainfrom
feat/agent-weight-system

Conversation

@Gaubee
Copy link
Copy Markdown
Collaborator

@Gaubee Gaubee commented Dec 19, 2025

Summary

Add a fair default ordering system for AI agents based on the current execution environment.

Problem

Previously, claude-code was hardcoded as the first priority, which wasn't fair when running in a Codex environment.

Solution

Detect the current Agent environment and adjust weights accordingly:

Environment Variable Condition Effect
CLAUDECODE truthy value JIXOFLOW_CLAUDECODE_WEIGHT += 1
CODEX_SANDBOX exists (any value) JIXOFLOW_CODEX_WEIGHT += 1

Behavior Examples

# Clean environment (no detection)
Weights: claude-code=0, codex=0
Default order: ["claude-code", "codex"]  // historical compatibility

# Running in Claude Code
CLAUDECODE=1 detected → claude-code weight +1
Default order: ["claude-code", "codex"]

# Running in Codex
CODEX_SANDBOX exists → codex weight +1
Default order: ["codex", "claude-code"]

# Nested Agent (Claude calls sub-agent)
Parent: JIXOFLOW_CLAUDECODE_WEIGHT=1
Child inherits env, detects CLAUDECODE again
Child: JIXOFLOW_CLAUDECODE_WEIGHT=2

User Config Priority

User's explicit .default() configuration completely overrides weight-based ordering.

Tests

Added 10 new test cases for the weight system (90 total tests passing).

- Detect CLAUDECODE (truthy) to increase claude-code weight
- Detect CODEX_SANDBOX (exists) to increase codex weight
- Weights stored in JIXOFLOW_*_WEIGHT env vars for subprocess inheritance
- Default profile order determined by weights (higher = priority)
- User config completely overrides weight-based ordering

This enables fair default ordering based on the current Agent environment,
supporting nested Agent scenarios where child processes inherit parent preferences.
@Gaubee Gaubee merged commit 5df9de7 into main Dec 19, 2025
3 checks passed
@Gaubee Gaubee deleted the feat/agent-weight-system branch December 19, 2025 12:25
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