fix(config): strip ANSI escape sequences from model names#114
Merged
tjb-tech merged 1 commit intoHKUDS:mainfrom Apr 11, 2026
Merged
fix(config): strip ANSI escape sequences from model names#114tjb-tech merged 1 commit intoHKUDS:mainfrom
tjb-tech merged 1 commit intoHKUDS:mainfrom
Conversation
When setting ANTHROPIC_MODEL or OPENHARNESS_MODEL environment variables in terminals with formatting (e.g., bold text), ANSI escape sequences like \x1b[1m can be inadvertently included in the model name. This causes the API to receive an invalid model name like 'claude-opus-4-6[1m]' instead of 'claude-opus-4-6', resulting in a 404 error. Changes: - Add strip_ansi_escape_sequences() helper function - Apply stripping in _apply_env_overrides() for env vars - Apply stripping in merge_cli_overrides() for CLI args - Add comprehensive tests for ANSI escape handling Fixes HKUDS#113
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue where ANSI escape sequences in the
ANTHROPIC_MODELorOPENHARNESS_MODELenvironment variables would cause API requests to fail with 404 errors.Problem
When users set the model environment variable in a terminal with formatting (e.g., bold text), ANSI escape sequences like
\x1b[1m(bold) and\x1b[0m(reset) can be inadvertently included. This results in the API receiving an invalid model name likeclaude-opus-4-6[1m]instead ofclaude-opus-4-6.Fixes #113
Changes
strip_ansi_escape_sequences()helper function insettings.pyto remove ANSI escape codes from text_apply_env_overrides()to strip ANSI sequences from model environment variablesmerge_cli_overrides()to strip ANSI sequences from CLI--modelargumentTestAnsiEscapeSequencestest classTesting
Checklist