Skip to content

Re-entering a context manager from set_config_context raises AttributeError instead of RuntimeError #30720

@Alioth99

Description

@Alioth99

Checked other resources

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Example Code

from langchain_core.runnables.config import set_config_context
from langchain_core.runnables import RunnableConfig

# Test context manager protocol violations
config = RunnableConfig(enabled=True)

# Test entering twice
ctx_manager = set_config_context(config)
with ctx_manager as ctx1:
    print("First enter")
    try:
        with ctx_manager as ctx2:
            print("Second enter")
            assert False, "Should raise RuntimeError"
    except RuntimeError:
        print("Caught expected RuntimeError on double enter")

# Test exiting without entering
try:
    ctx_manager.__exit__(None, None, None)
    assert False, "Should raise RuntimeError"
except RuntimeError:
    print("Caught expected RuntimeError on exit without enter")

Error Message and Stack Trace (if applicable)

First enter
Traceback (most recent call last):
  File "test_case.py", line 13, in <module>
    with ctx_manager as ctx2:
  File ".../lib/python3.10/contextlib.py", line 133, in __enter__
    del self.args, self.kwds, self.func
AttributeError: args

Description

  • I'm trying to test the behavior of the set_config_context context manager in langchain_core.runnables.config.

  • I expect it to raise a RuntimeError or give a clear error when trying to enter the context manager twice or exit without entering.

  • Instead, entering the same context manager twice raises a non-obvious AttributeError: args, coming from Python's contextlib.py.

This is confusing and not safe for user code, since it violates context manager protocol silently and crashes due to internals of contextlib.

System Info

System Information

OS: Linux
OS Version: #107-Ubuntu SMP Wed Feb 7 13:26:48 UTC 2024
Python Version: 3.10.16 (main, Dec 11 2024, 16:24:50) [GCC 11.2.0]

Package Information

langchain_core: 0.3.50
langchain: 0.3.22
langchain_community: 0.3.13
langsmith: 0.3.23
langchain_anthropic: 0.3.1
langchain_aws: 0.2.2
langchain_chroma: 0.2.0
langchain_experimental: 0.3.2
langchain_fireworks: 0.2.6
langchain_google_vertexai: 2.0.5
langchain_groq: 0.2.2
langchain_mistralai: 0.2.4
langchain_openai: 0.2.14
langchain_text_splitters: 0.3.7
langchain_together: 0.2.0
langchain_unstructured: 0.1.5
langgraph_sdk: 0.1.34

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.10.10
anthropic: 0.40.0
anthropic[vertexai]: Installed. No version info available.
async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
boto3: 1.35.42
chromadb: 0.5.15
dataclasses-json: 0.6.7
defusedxml: 0.7.1
fastapi: 0.115.3
fireworks-ai: 0.15.7
google-cloud-aiplatform: 1.70.0
google-cloud-storage: 2.18.2
groq: 0.11.0
httpx: 0.28.1
httpx-sse: 0.4.0
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-anthropic;: Installed. No version info available.
langchain-aws;: Installed. No version info available.
langchain-azure-ai;: Installed. No version info available.
langchain-cohere;: Installed. No version info available.
langchain-community;: Installed. No version info available.
langchain-core<1.0.0,>=0.3.45: Installed. No version info available.
langchain-core<1.0.0,>=0.3.49: Installed. No version info available.
langchain-deepseek;: Installed. No version info available.
langchain-fireworks;: Installed. No version info available.
langchain-google-genai;: Installed. No version info available.
langchain-google-vertexai;: Installed. No version info available.
langchain-groq;: Installed. No version info available.
langchain-huggingface;: Installed. No version info available.
langchain-mistralai;: Installed. No version info available.
langchain-ollama;: Installed. No version info available.
langchain-openai;: Installed. No version info available.
langchain-text-splitters<1.0.0,>=0.3.7: Installed. No version info available.
langchain-together;: Installed. No version info available.
langchain-xai;: Installed. No version info available.
langsmith-pyo3: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
langsmith<0.4,>=0.1.17: Installed. No version info available.
numpy: 1.26.4
openai: 1.57.4
openai-agents: Installed. No version info available.
opentelemetry-api: 1.27.0
opentelemetry-exporter-otlp-proto-http: Installed. No version info available.
opentelemetry-sdk: 1.27.0
orjson: 3.10.16
packaging: 24.1
packaging<25,>=23.2: Installed. No version info available.
pydantic: 2.11.1
pydantic-settings: 2.6.0
pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
pydantic<3.0.0,>=2.7.4: Installed. No version info available.
pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
pytest: 8.3.4
PyYAML: 6.0.2
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.3
requests-toolbelt: 1.0.0
requests<3,>=2: Installed. No version info available.
rich: 13.9.3
SQLAlchemy: 2.0.40
SQLAlchemy<3,>=1.4: Installed. No version info available.
tenacity: 9.1.2
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
tiktoken: 0.8.0
tokenizers: 0.21.0
typing-extensions>=4.7: Installed. No version info available.
unstructured-client: 0.25.9
unstructured[all-docs]: Installed. No version info available.
zstandard: 0.23.0

Agent Context { "tasks": [ { "id": "4537e045-5da3-472a-9087-a40af572d865", "taskIndex": 0, "request": "[original issue]\n**Re-entering a context manager from `set_config_context` raises `AttributeError` instead of `RuntimeError`**\n### Checked other resources\n\n- [x] I added a very descriptive title to this issue.\n- [x] I used the GitHub search to find a similar question and didn't find it.\n- [x] I am sure that this is a bug in LangChain rather than my code.\n- [x] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).\n- [x] I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.\n\n### Example Code\n\n```python\nfrom langchain_core.runnables.config import set_config_context\nfrom langchain_core.runnables import RunnableConfig\n\n# Test context manager protocol violations\nconfig = RunnableConfig(enabled=True)\n\n# Test entering twice\nctx_manager = set_config_context(config)\nwith ctx_manager as ctx1:\n print(\"First enter\")\n try:\n with ctx_manager as ctx2:\n print(\"Second enter\")\n assert False, \"Should raise RuntimeError\"\n except RuntimeError:\n print(\"Caught expected RuntimeError on double enter\")\n\n# Test exiting without entering\ntry:\n ctx_manager.__exit__(None, None, None)\n assert False, \"Should raise RuntimeError\"\nexcept RuntimeError:\n print(\"Caught expected RuntimeError on exit without enter\")\n```\n\n### Error Message and Stack Trace (if applicable)\n\n```python\nFirst enter\nTraceback (most recent call last):\n File \"test_case.py\", line 13, in \n with ctx_manager as ctx2:\n File \".../lib/python3.10/contextlib.py\", line 133, in __enter__\n del self.args, self.kwds, self.func\nAttributeError: args\n```\n\n### Description\n\n- I'm trying to test the behavior of the `set_config_context` context manager in` langchain_core.runnables.config`.\n\n- I expect it to raise a `RuntimeError` or give a clear error when trying to enter the context manager twice or exit without entering.\n\n- Instead, entering the same context manager twice raises a non-obvious `AttributeError: args`, coming from Python's `contextlib.py`.\n\nThis is confusing and not safe for user code, since it violates context manager protocol silently and crashes due to internals of `contextlib`.\n\n### System Info\n\nSystem Information\n------------------\n> OS: Linux\n> OS Version: #107-Ubuntu SMP Wed Feb 7 13:26:48 UTC 2024\n> Python Version: 3.10.16 (main, Dec 11 2024, 16:24:50) [GCC 11.2.0]\n\nPackage Information\n-------------------\n> langchain_core: 0.3.50\n> langchain: 0.3.22\n> langchain_community: 0.3.13\n> langsmith: 0.3.23\n> langchain_anthropic: 0.3.1\n> langchain_aws: 0.2.2\n> langchain_chroma: 0.2.0\n> langchain_experimental: 0.3.2\n> langchain_fireworks: 0.2.6\n> langchain_google_vertexai: 2.0.5\n> langchain_groq: 0.2.2\n> langchain_mistralai: 0.2.4\n> langchain_openai: 0.2.14\n> langchain_text_splitters: 0.3.7\n> langchain_together: 0.2.0\n> langchain_unstructured: 0.1.5\n> langgraph_sdk: 0.1.34\n\nOptional packages not installed\n-------------------------------\n> langserve\n\nOther Dependencies\n------------------\n> aiohttp: 3.10.10\n> anthropic: 0.40.0\n> anthropic[vertexai]: Installed. No version info available.\n> async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.\n> boto3: 1.35.42\n> chromadb: 0.5.15\n> dataclasses-json: 0.6.7\n> defusedxml: 0.7.1\n> fastapi: 0.115.3\n> fireworks-ai: 0.15.7\n> google-cloud-aiplatform: 1.70.0\n> google-cloud-storage: 2.18.2\n> groq: 0.11.0\n> httpx: 0.28.1\n> httpx-sse: 0.4.0\n> jsonpatch<2.0,>=1.33: Installed. No version info available.\n> langchain-anthropic;: Installed. No version info available.\n> langchain-aws;: Installed. No version info available.\n> langchain-azure-ai;: Installed. No version info available.\n> langchain-cohere;: Installed. No version info available.\n> langchain-community;: Installed. No version info available.\n> langchain-core<1.0.0,>=0.3.45: Installed. No version info available.\n> langchain-core<1.0.0,>=0.3.49: Installed. No version info available.\n> langchain-deepseek;: Installed. No version info available.\n> langchain-fireworks;: Installed. No version info available.\n> langchain-google-genai;: Installed. No version info available.\n> langchain-google-vertexai;: Installed. No version info available.\n> langchain-groq;: Installed. No version info available.\n> langchain-huggingface;: Installed. No version info available.\n> langchain-mistralai;: Installed. No version info available.\n> langchain-ollama;: Installed. No version info available.\n> langchain-openai;: Installed. No version info available.\n> langchain-text-splitters<1.0.0,>=0.3.7: Installed. No version info available.\n> langchain-together;: Installed. No version info available.\n> langchain-xai;: Installed. No version info available.\n> langsmith-pyo3: Installed. No version info available.\n> langsmith<0.4,>=0.1.125: Installed. No version info available.\n> langsmith<0.4,>=0.1.17: Installed. No version info available.\n> numpy: 1.26.4\n> openai: 1.57.4\n> openai-agents: Installed. No version info available.\n> opentelemetry-api: 1.27.0\n> opentelemetry-exporter-otlp-proto-http: Installed. No version info available.\n> opentelemetry-sdk: 1.27.0\n> orjson: 3.10.16\n> packaging: 24.1\n> packaging<25,>=23.2: Installed. No version info available.\n> pydantic: 2.11.1\n> pydantic-settings: 2.6.0\n> pydantic<3.0.0,>=2.5.2;: Installed. No version info available.\n> pydantic<3.0.0,>=2.7.4: Installed. No version info available.\n> pydantic<3.0.0,>=2.7.4;: Installed. No version info available.\n> pytest: 8.3.4\n> PyYAML: 6.0.2\n> PyYAML>=5.3: Installed. No version info available.\n> requests: 2.32.3\n> requests-toolbelt: 1.0.0\n> requests<3,>=2: Installed. No version info available.\n> rich: 13.9.3\n> SQLAlchemy: 2.0.40\n> SQLAlchemy<3,>=1.4: Installed. No version info available.\n> tenacity: 9.1.2\n> tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.\n> tiktoken: 0.8.0\n> tokenizers: 0.21.0\n> typing-extensions>=4.7: Installed. No version info available.\n> unstructured-client: 0.25.9\n> unstructured[all-docs]: Installed. No version info available.\n> zstandard: 0.23.0", "title": "Fix set_config_context to raise RuntimeError instead of AttributeError on context manager reuse", "createdAt": 1757462037762, "completed": true, "planRevisions": [ { "revisionIndex": 0, "plans": [ { "index": 0, "plan": "**Replace generator-based context manager with class-based implementation in `/home/daytona/langchain/libs/core/langchain_core/runnables/config.py`**\n- Remove the `@contextmanager` decorator from `set_config_context` function (line 157)\n- Create a new class `ConfigContext` that implements `__enter__` and `__exit__` methods\n- Track state with `_entered` flag to detect and prevent reuse\n- In `__enter__`: Check if already entered and raise `RuntimeError` with message \"Cannot re-enter an already-entered context manager\"\n- In `__exit__`: Check if not entered and raise `RuntimeError` with message \"Cannot exit context manager that was not entered\"\n- Preserve the exact same functionality as the current implementation: copy context, set config token, yield context, and reset on exit\n- Update `set_config_context` function to return an instance of `ConfigContext` instead of using generator", "completed": true, "summary": "Successfully replaced the generator-based context manager with a class-based implementation in `/home/daytona/langchain/libs/core/langchain_core/runnables/config.py`.\n\n**Changes made:**\n1. Created a new `ConfigContext` class that implements proper context manager protocol with `__enter__` and `__exit__` methods\n2. Added state tracking with `_entered` flag to detect and prevent reuse\n3. Implemented proper error handling:\n - Raises `RuntimeError(\"Cannot re-enter an already-entered context manager\")` when attempting to enter an already-entered context\n - Raises `RuntimeError(\"Cannot exit context manager that was not entered\")` when attempting to exit without entering\n4. Preserved exact same functionality as the original implementation:\n - Copies context using `copy_context()`\n - Sets config token via `_set_config_context`\n - Returns the context on enter\n - Properly resets config and tracing context on exit\n5. Updated `set_config_context` function to return an instance of `ConfigContext` instead of using the `@contextmanager` decorator\n\n**Verification:**\n- Created and ran verification script that confirms all error cases are properly handled\n- Normal usage continues to work correctly\n- Nested contexts with different instances work as expected\n- The implementation now provides clear, actionable error messages instead of confusing `AttributeError` from Python's contextlib" }, { "index": 1, "plan": "**Add comprehensive unit tests for context manager protocol violations in `/home/daytona/langchain/libs/core/tests/unit_tests/runnables/test_config.py`**\n- Add test `test_set_config_context_reuse_raises_error()` to verify RuntimeError is raised when entering the same context manager twice\n- Add test `test_set_config_context_exit_without_enter()` to verify RuntimeError is raised when exiting without entering\n- Add test `test_set_config_context_normal_usage()` to ensure normal usage still works correctly\n- Add test `test_set_config_context_nested_different_instances()` to verify that using different instances in nested contexts works properly\n- Ensure all tests use proper assertions and error message validation", "completed": true, "summary": "Successfully added comprehensive unit tests for context manager protocol violations in `/home/daytona/langchain/libs/core/tests/unit_tests/runnables/test_config.py`.\n\n**Tests added:**\n1. **`test_set_config_context_reuse_raises_error()`** - Verifies that attempting to enter the same context manager twice raises a `RuntimeError` with the message \"Cannot re-enter an already-entered context manager\"\n2. **`test_set_config_context_exit_without_enter()`** - Verifies that calling `__exit__` without entering raises a `RuntimeError` with the message \"Cannot exit context manager that was not entered\"\n3. **`test_set_config_context_normal_usage()`** - Ensures normal usage continues to work correctly, verifying that the context is properly returned and is a `contextvars.Context` object\n4. **`test_set_config_context_nested_different_instances()`** - Verifies that using different context manager instances in nested contexts works properly, ensuring both contexts are valid and distinct\n\n**Test verification:**\n- All four tests have been individually run and pass successfully\n- Tests use proper `pytest.raises` assertions to verify exceptions\n- Error messages are validated to ensure they match the expected text\n- Tests cover all edge cases identified in the original issue\n- Normal usage patterns are preserved and tested" }, { "index": 2, "plan": "**Run tests and code quality checks**\n- Run `make test` to ensure all unit tests pass\n- Run `make lint` to check code style compliance\n- Run `make format` to format the code according to project standards\n- Verify that the changes don't break any existing functionality by running the specific test file: `uv run --group test pytest libs/core/tests/unit_tests/runnables/test_config.py -v`", "completed": true, "summary": "Successfully completed all tests and code quality checks for the context manager implementation.\n\n**Test Results:**\n- ✅ Ran specific test file: All 8 tests in `test_config.py` passed, including 4 new tests\n- ✅ Ran unit test suite: 1339 tests passed (1 unrelated failure in rate limiting test)\n- ✅ Verification script: Confirms all context manager functionality works correctly\n\n**Code Quality:**\n- ✅ Fixed linting issues:\n - Extracted error messages into variables (EM101, TRY003)\n - Fixed type annotation for `exc_tb` parameter (PYI036)\n - Added `TracebackType` import\n - Removed redundant imports in test file\n- ✅ Code formatting applied via `make format`\n- Minor style warning (SIM117) about nested `with` statements remains, which is intentional for testing the error case\n\n**Functionality Verification:**\n- Context manager reuse properly raises `RuntimeError` with clear message\n- Exit without enter properly raises `RuntimeError` with clear message\n- Normal usage continues to work correctly\n- Nested contexts with different instances work as expected\n- No existing functionality was broken by the changes\n\nThe implementation successfully addresses the original issue where reusing a context manager would cause a confusing `AttributeError`, now providing clear and actionable error messages." } ], "createdAt": 1757462037762, "createdBy": "agent" }, { "revisionIndex": 1, "plans": [ { "index": 0, "plan": "**Replace generator-based context manager with class-based implementation in `/home/daytona/langchain/libs/core/langchain_core/runnables/config.py`**\n- Remove the `@contextmanager` decorator from `set_config_context` function (line 157)\n- Create a new class `ConfigContext` that implements `__enter__` and `__exit__` methods\n- Track state with `_entered` flag to detect and prevent reuse\n- In `__enter__`: Check if already entered and raise `RuntimeError` with message \"Cannot re-enter an already-entered context manager\"\n- In `__exit__`: Check if not entered and raise `RuntimeError` with message \"Cannot exit context manager that was not entered\"\n- Preserve the exact same functionality as the current implementation: copy context, set config token, yield context, and reset on exit\n- Update `set_config_context` function to return an instance of `ConfigContext` instead of using generator", "completed": true, "summary": "Successfully replaced the generator-based context manager with a class-based implementation in `/home/daytona/langchain/libs/core/langchain_core/runnables/config.py`.\n\n**Changes made:**\n1. Created a new `ConfigContext` class that implements proper context manager protocol with `__enter__` and `__exit__` methods\n2. Added state tracking with `_entered` flag to detect and prevent reuse\n3. Implemented proper error handling:\n - Raises `RuntimeError(\"Cannot re-enter an already-entered context manager\")` when attempting to enter an already-entered context\n - Raises `RuntimeError(\"Cannot exit context manager that was not entered\")` when attempting to exit without entering\n4. Preserved exact same functionality as the original implementation:\n - Copies context using `copy_context()`\n - Sets config token via `_set_config_context`\n - Returns the context on enter\n - Properly resets config and tracing context on exit\n5. Updated `set_config_context` function to return an instance of `ConfigContext` instead of using the `@contextmanager` decorator\n\n**Verification:**\n- Created and ran verification script that confirms all error cases are properly handled\n- Normal usage continues to work correctly\n- Nested contexts with different instances work as expected\n- The implementation now provides clear, actionable error messages instead of confusing `AttributeError` from Python's contextlib" }, { "index": 1, "plan": "**Add comprehensive unit tests for context manager protocol violations in `/home/daytona/langchain/libs/core/tests/unit_tests/runnables/test_config.py`**\n- Add test `test_set_config_context_reuse_raises_error()` to verify RuntimeError is raised when entering the same context manager twice\n- Add test `test_set_config_context_exit_without_enter()` to verify RuntimeError is raised when exiting without entering\n- Add test `test_set_config_context_normal_usage()` to ensure normal usage still works correctly\n- Add test `test_set_config_context_nested_different_instances()` to verify that using different instances in nested contexts works properly\n- Ensure all tests use proper assertions and error message validation", "completed": true, "summary": "Successfully added comprehensive unit tests for context manager protocol violations in `/home/daytona/langchain/libs/core/tests/unit_tests/runnables/test_config.py`.\n\n**Tests added:**\n1. **`test_set_config_context_reuse_raises_error()`** - Verifies that attempting to enter the same context manager twice raises a `RuntimeError` with the message \"Cannot re-enter an already-entered context manager\"\n2. **`test_set_config_context_exit_without_enter()`** - Verifies that calling `__exit__` without entering raises a `RuntimeError` with the message \"Cannot exit context manager that was not entered\"\n3. **`test_set_config_context_normal_usage()`** - Ensures normal usage continues to work correctly, verifying that the context is properly returned and is a `contextvars.Context` object\n4. **`test_set_config_context_nested_different_instances()`** - Verifies that using different context manager instances in nested contexts works properly, ensuring both contexts are valid and distinct\n\n**Test verification:**\n- All four tests have been individually run and pass successfully\n- Tests use proper `pytest.raises` assertions to verify exceptions\n- Error messages are validated to ensure they match the expected text\n- Tests cover all edge cases identified in the original issue\n- Normal usage patterns are preserved and tested" }, { "index": 2, "plan": "**Run tests and code quality checks**\n- Run `make test` to ensure all unit tests pass\n- Run `make lint` to check code style compliance\n- Run `make format` to format the code according to project standards\n- Verify that the changes don't break any existing functionality by running the specific test file: `uv run --group test pytest libs/core/tests/unit_tests/runnables/test_config.py -v`", "completed": true, "summary": "Successfully completed all tests and code quality checks for the context manager implementation.\n\n**Test Results:**\n- ✅ Ran specific test file: All 8 tests in `test_config.py` passed, including 4 new tests\n- ✅ Ran unit test suite: 1339 tests passed (1 unrelated failure in rate limiting test)\n- ✅ Verification script: Confirms all context manager functionality works correctly\n\n**Code Quality:**\n- ✅ Fixed linting issues:\n - Extracted error messages into variables (EM101, TRY003)\n - Fixed type annotation for `exc_tb` parameter (PYI036)\n - Added `TracebackType` import\n - Removed redundant imports in test file\n- ✅ Code formatting applied via `make format`\n- Minor style warning (SIM117) about nested `with` statements remains, which is intentional for testing the error case\n\n**Functionality Verification:**\n- Context manager reuse properly raises `RuntimeError` with clear message\n- Exit without enter properly raises `RuntimeError` with clear message\n- Normal usage continues to work correctly\n- Nested contexts with different instances work as expected\n- No existing functionality was broken by the changes\n\nThe implementation successfully addresses the original issue where reusing a context manager would cause a confusing `AttributeError`, now providing clear and actionable error messages." }, { "index": 3, "plan": "Remove development script: test_context_manager_fix.py", "completed": true, "summary": "Successfully removed the development script `test_context_manager_fix.py` from the repository root.\n\n**Action taken:**\n- Executed `rm /home/daytona/langchain/test_context_manager_fix.py` to delete the file\n- Verified removal by confirming the file no longer exists\n\nThis development script was used during the implementation phase to test the context manager fix and is no longer needed now that the proper implementation and tests are in place." }, { "index": 4, "plan": "Remove development script: verify_fix.py", "completed": true, "summary": "Successfully removed the development script `verify_fix.py` from the repository root.\n\n**Action taken:**\n- Executed `rm /home/daytona/langchain/verify_fix.py` to delete the file\n- Verified removal by confirming the file no longer exists (ls command returns \"No such file or directory\")\n\nThis verification script was used during development to test the context manager implementation and is no longer needed now that proper unit tests have been added to the test suite." }, { "index": 5, "plan": "Run final linting check to ensure code meets project standards", "completed": true, "summary": "Successfully completed the final linting check to ensure code meets project standards.\n\n**Linting Results:**\n- ✅ **Ruff check**: All checks passed - no style violations\n- ✅ **Ruff format**: 315 files already formatted - code is properly formatted\n- ✅ **Mypy type checking**: Success - no issues found in 315 source files\n\n**Actions taken to achieve compliance:**\n1. Fixed error message handling by extracting messages into variables (EM101, TRY003 rules)\n2. Fixed type annotation for `exc_tb` parameter to use `TracebackType`\n3. Added necessary imports (`TracebackType` from `types`, `Context` from `contextvars`)\n4. Removed redundant imports from test functions\n5. Reformatted test to avoid nested `with` statements issue\n6. Removed trailing blank lines from files\n\nThe implementation now fully complies with the project's code quality standards while maintaining all functionality and test coverage." } ], "createdAt": 1757462851147, "createdBy": "agent" } ], "activeRevisionIndex": 1, "pullRequestNumber": 32875, "completedAt": 1757463148292, "summary": "I've successfully implemented a robust class-based context manager for `set_config_context` that replaces the generator-based implementation. The new implementation provides clear `RuntimeError` messages when context manager protocol is violated, with comprehensive unit tests and full code quality compliance. Key changes include creating a `ConfigContext` class with proper state tracking, adding 4 new unit tests, and ensuring all existing functionality is preserved while improving error handling." } ], "activeTaskIndex": 0 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featureinvestigateFlagged for investigationopen-swe-max-autofor langchain-ai/open-swe - let agent decide tasks (opus 4)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions