Skip to content

Fix OAuth callbacks and extension module loading#1

Open
xlr8harder wants to merge 1 commit into
secemp9:masterfrom
xlr8harder:fix-codex-login-extension-loader
Open

Fix OAuth callbacks and extension module loading#1
xlr8harder wants to merge 1 commit into
secemp9:masterfrom
xlr8harder:fix-codex-login-extension-loader

Conversation

@xlr8harder

Copy link
Copy Markdown

Summary

This fixes two harn runtime issues found while dogfooding harn-gibson as a harn extension:

  • Pass OAuth login callbacks as an attribute-style callback object instead of a dict.
  • Register extension modules in sys.modules before executing them, matching normal import behavior.

Why

Interactive /login for the openai-codex provider currently fails because the OAuth provider expects callbacks.onAuth, but interactive mode passes {"onAuth": ...}. This produces:

'dict' object has no attribute 'onAuth'

Separately, extension files are executed via exec_module() without being inserted into sys.modules. Some standard Python machinery, including dataclasses with postponed annotations, expects sys.modules[cls.__module__] to exist during class creation. Without that, valid extension code can fail during load.

Changes

  • Updated interactive login callback construction to use SimpleNamespace.
  • Updated extension loading to insert the module into sys.modules before exec_module().
  • Restores the prior sys.modules entry, or removes the temporary entry, if extension execution fails.
  • Added regression coverage for both behaviors.

Testing

Ran targeted regressions:

uv run --no-sync --all-packages pytest tests/test_coding_agent/test_interactive_mode_foundation.py::test_show_login_dialog_only_collects_manual_code_for_callback_providers tests/test_coding_agent/ test_resources_and_extensions.py::test_extension_loader_registers_modules_for_dataclass_annotations -q

Result: 2 passed

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