Skip to content

[BUG] [v0.0.7] cortex acp --agent ignores CORTEX_HOME — always scans ~/.cortex for agents #51939

Description

@tireless75-cmyk

Summary

cortex acp --agent <name> hardcodes the agent registry path to ~/.cortex instead of using the CORTEX_HOME environment variable. Agents stored in the custom home directory are never found.

Steps to Reproduce

# Create an agent in the custom CORTEX_HOME
mkdir -p /tmp/custom_cortex_home/agents/testacpagent
cat > /tmp/custom_cortex_home/agents/testacpagent/AGENT.md << 'EOF'
---
name: testacpagent
description: Test agent
---
EOF

# Run with CORTEX_HOME pointing to the custom directory
CORTEX_HOME=/tmp/custom_cortex_home CORTEX_API_KEY=ctx-fake cortex acp --agent testacpagent

Expected Behavior

cortex acp --agent testacpagent should find the agent in $CORTEX_HOME/agents/testacpagent/.

Actual Behavior

Error: Agent not found: 'testacpagent'. Use 'cortex agent list' to see available agents.

The command fails because it looks in ~/.cortex/agents/ instead of /tmp/custom_cortex_home/agents/.

Screenshot

acp CORTEX_HOME bug

Root Cause

File: src/cortex-cli/src/acp_cmd.rs, lines 61–63

// BUGGY — hardcodes ~/.cortex, ignores CORTEX_HOME
let cortex_home = dirs::home_dir()
    .map(|h| h.join(".cortex"))
    .ok_or_else(|| anyhow::anyhow!("Could not determine home directory"))?;

The correct pattern used by other commands is:

// CORRECT — respects CORTEX_HOME
let cortex_home = crate::utils::paths::get_cortex_home();

The get_cortex_home() function in utils/paths.rs properly checks the CORTEX_HOME environment variable. The acp_cmd.rs bypasses this and always uses ~/.cortex.

Version

cortex v0.0.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions