Skip to content

v2.1.2: Compliance Updates + Critical Bug Fixes

Choose a tag to compare

@numman-ali numman-ali released this 12 Oct 20:31
· 49 commits to main since this release

v2.1.2: Compliance Updates + Critical Bug Fixes

This release includes comprehensive OpenAI ToS compliance updates and fixes 4 critical bugs that prevented per-model options and multi-turn conversations from working correctly.


🔒 Compliance & Legal Updates

Terms of Service & Usage Guidelines

This release adds comprehensive compliance documentation to ensure users understand proper usage:

  • ⚠️ Terms of Service & Usage Notice - Clear guidance on personal use only
  • 📋 Rate Limits & Responsible Use - Best practices for API usage
  • ❓ Frequently Asked Questions - 6 common TOS compliance questions
  • 📄 LICENSE Update - MIT with Usage Disclaimer for personal development
  • 💼 Compliance Header - Added to index.ts documenting intended use

Key Points:

  • ✅ For personal development only with your own ChatGPT Plus/Pro subscription
  • ✅ Uses OpenAI's official OAuth authentication (same as Codex CLI)
  • ❌ NOT for: Commercial resale, multi-user services, or API resale
  • ❌ NOT a "free API alternative" - uses your existing subscription
  • 📋 Users are responsible for compliance with OpenAI's Terms of Use

New Documentation Files

Compliance & Security:

  • CONTRIBUTING.md - Contribution guidelines with compliance requirements
  • SECURITY.md - Security policy, vulnerability reporting, best practices
  • docs/privacy.md - Comprehensive privacy & data handling documentation

User Guides:

  • docs/getting-started.md - Complete installation guide with compliance notice
  • docs/configuration.md - Advanced configuration options
  • docs/troubleshooting.md - Debug techniques and compliance troubleshooting

Developer Guides:

  • docs/development/ARCHITECTURE.md - Technical architecture deep dive
  • docs/development/CONFIG_FLOW.md - Config system internals
  • docs/development/CONFIG_FIELDS.md - Field usage guide
  • docs/development/TESTING.md - Testing guide and verification

GitHub Templates:

  • .github/ISSUE_TEMPLATE/bug_report.md - Bug reports with compliance checklist
  • .github/ISSUE_TEMPLATE/feature_request.md - Feature requests with compliance confirmation
  • .github/ISSUE_TEMPLATE/config.yml - Links to OpenAI support and TOS

🐛 Critical Bug Fixes

Bug #1: Per-Model Options Ignored (Config Lookup Mismatch)

Severity: 🔴 HIGH

Problem:
Users configured different reasoningEffort for each model variant (low/medium/high), but all variants behaved identically. The plugin was normalizing model names before config lookup, causing it to miss per-model configurations.

Fix: lib/request/request-transformer.ts:277

  • Use original model name for config lookup
  • Normalize only for API request
  • Per-model options now correctly applied ✅

Impact:

  • ✅ Different reasoning levels properly applied per variant
  • ✅ Users can customize each model independently

Bug #2: Multi-Turn Conversations Fail (AI SDK Compatibility)

Severity: 🔴 CRITICAL

Problem:
Multi-turn conversations failed with: AI_APICallError: Item with id 'msg_abc123' not found. Items are not persisted when store is set to false.

Root Causes:

  1. AI SDK sends item_reference (not in Codex API spec)
  2. IDs weren't completely stripped for stateless mode
  3. Only rs_* IDs were filtered, but msg_*, assistant_* leaked through

Research:

  • Tested store: true → API returned error (ChatGPT backend requires store: false)
  • Codex CLI never sends ANY IDs in stateless mode
  • Full message history needed for LLM context

Fix: lib/request/request-transformer.ts:114-135

  • Filter out AI SDK item_reference items
  • Strip ALL IDs from remaining items (not just rs_*)
  • Preserve full message history for LLM context

Impact:

  • ✅ No more "item not found" errors
  • ✅ Multi-turn conversations work flawlessly
  • ✅ Full context preserved via reasoning.encrypted_content

Bug #3: Case-Sensitive Normalization

Severity: 🟡 MEDIUM

Problem:
Old verbose config names like "GPT 5 Codex Low (ChatGPT Subscription)" didn't normalize correctly because pattern matching was case-sensitive.

Fix: lib/request/request-transformer.ts:22-27

  • Added toLowerCase() for case-insensitive matching
  • Handles uppercase/mixed case user input

Impact:

  • ✅ Backwards compatible with old verbose config names
  • ✅ Old configs work seamlessly

Bug #4: GitHub API Rate Limiting

Severity: 🟡 MEDIUM

Problem:
Plugin checked GitHub on every request to fetch latest Codex instructions, exhausting the 60 req/hour rate limit during testing.

Fix: lib/prompts/codex.ts:50-53, lib/prompts/opencode-codex.ts:47-50

  • Added 15-minute cache TTL check
  • Only fetches if cache is stale

Impact:

  • ✅ Prevents rate limit exhaustion
  • ✅ Faster plugin initialization

✨ Enhancements

Debug Logging System

New environment variable for troubleshooting:

DEBUG_CODEX_PLUGIN=1 opencode run "test"

Shows:

  • Config lookups and option resolution
  • Message ID filtering
  • Model normalization
  • Per-model vs global options

New functions: logDebug() and logWarn() in lib/logger.ts


Optimized Config Structure

New Recommended Config:

{
  "models": {
    "gpt-5-codex-low": {
      "name": "GPT 5 Codex Low (OAuth)",
      "options": { "reasoningEffort": "low" }
    }
  }
}

Improvements:

  • ✅ Matches Codex CLI official preset IDs
  • ✅ Cleaner CLI usage: --model=openai/gpt-5-codex-low
  • ✅ Removed redundant id field
  • ✅ Added name field for TUI display

File: config/full-opencode.json

Note: Old config format still fully supported (100% backwards compatible)


Automated Testing

Created scripts/test-all-models.sh for automated integration testing:

  • Tests all 9 custom model configurations
  • Tests all 4 default OpenCode models
  • Verifies backwards compatibility
  • Uses ENABLE_PLUGIN_REQUEST_LOGGING to verify actual API requests

🧪 Testing

Test Coverage

  • ✅ 159 unit tests passing (30+ new tests added)
  • ✅ 14 integration tests passing (actual API verification)
  • ✅ All documented scenarios have test coverage

Integration Test Results

✅ 14/14 model configuration tests passing
✅ All 9 custom models verified
✅ All 4 default models verified
✅ Backwards compatibility confirmed
✅ Multi-turn conversations tested successfully

📝 Breaking Changes

None! This release is 100% backwards compatible.

Old configs continue to work:

  • Verbose names like "GPT 5 Codex Low (ChatGPT Subscription)" ✅
  • Configs with id field ✅
  • All existing configurations ✅

📦 What's Changed

Modified (9 files, +600 lines)

  • lib/request/request-transformer.ts - Config lookup & ID filtering fixes
  • lib/prompts/codex.ts - 15-minute cache TTL
  • lib/prompts/opencode-codex.ts - 15-minute cache TTL
  • lib/logger.ts - Debug logging system
  • config/full-opencode.json - Optimized structure
  • test/request-transformer.test.ts - 30+ new tests
  • LICENSE - Added usage disclaimer
  • index.ts - Added compliance header
  • README.md - Added ToS, Rate Limits, FAQ sections

Created (20 files, +4,500 lines)

  • Complete documentation suite (user + developer guides)
  • Privacy, security, and contribution policies
  • GitHub issue templates
  • Automated testing script

🎯 Verification

All scenarios tested and verified:

  • ✅ Default models work without custom config
  • ✅ Custom models with per-variant options
  • ✅ Old config format (backwards compatible)
  • ✅ Multi-turn conversations (no errors)
  • ✅ Model switching with different options
  • ✅ Complete ID filtering
  • ✅ 100% backwards compatibility

📚 Documentation

Complete documentation now available:


🔗 Important Links


⚠️ Usage Reminder

This plugin is for personal development use only with your own ChatGPT Plus/Pro subscription. It uses OpenAI's official OAuth authentication (same as Codex CLI).

Not for: Commercial services, API resale, or multi-user applications.

For production applications, use the OpenAI Platform API.


🚀 Upgrade Instructions

Update the Plugin

OpenCode does NOT auto-update plugins. To get v2.1.2:

# Clear plugin cache
(cd ~ && sed -i.bak '/"opencode-openai-codex-auth"/d' .cache/opencode/package.json && rm -rf .cache/opencode/node_modules/opencode-openai-codex-auth)

# Restart OpenCode - it will reinstall latest version
opencode

Optional: Migrate Config

Your existing config continues to work, but you can optionally migrate to the cleaner structure:

Before:

{
  "GPT 5 Codex Low (ChatGPT Subscription)": {
    "id": "gpt-5-codex",
    "options": { "reasoningEffort": "low" }
  }
}

After:

{
  "gpt-5-codex-low": {
    "name": "GPT 5 Codex Low (OAuth)",
    "options": { "reasoningEffort": "low" }
  }
}

🎉 What's Next

This release completes the v2.1.x series with comprehensive bug fixes, compliance coverage, and documentation.

Coming in future releases:

  • Additional model presets
  • Enhanced debugging capabilities
  • Performance optimizations

Full Changelog: v2.1.1...v2.1.2