Files
langchain/libs/core/langchain_core/utils
Alvin Tang 95fe150ad2 fix(core): _parse_google_docstring mishandling continuation lines with colons (#35680)
## Description

`_parse_google_docstring` incorrectly parses multi-line argument
descriptions when a continuation line contains a colon. The continuation
line is treated as a new argument definition instead of being appended
to the current argument's description.

### Example

```python
def search(query: str, top_k: int = 5) -> str:
    """Search the knowledge base.

    Args:
        query: The search query to use
            for finding things: important ones
        top_k: Number of results to return
    """
```

**Before (broken):** The parser creates 3 args: `query`, `for finding
things`, `top_k`
**After (fixed):** The parser correctly creates 2 args: `query` (with
full description including "for finding things: important ones"),
`top_k`

### Root Cause

The parser used `if ":" in line` to detect new argument lines without
considering indentation. In Google-style docstrings, continuation lines
have deeper indentation than argument definition lines.

### Fix

Detect the base indentation level from the first argument line and treat
any line with deeper indentation as a continuation of the current
argument's description, regardless of whether it contains a colon.

## Issue

Fixes #35679

## Dependencies

None.

## Testing

Added 4 unit tests in
`test_function_calling.py::TestParseGoogleDocstring`:
- `test_continuation_line_with_colon` — the core bug scenario
- `test_simple_args_still_work` — regression check for basic args
- `test_continuation_line_without_colon` — multi-line descriptions
without colons
- `test_multiple_continuation_lines_with_colons` — multiple continuation
lines each containing colons

All tests pass locally with Python 3.12.

---------

Co-authored-by: gambletan <ethanchang32@gmail.com>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
2026-06-23 00:34:02 -04:00
..
2025-10-15 18:46:55 -04:00
2026-01-23 23:07:48 -05:00
2026-01-23 23:07:48 -05:00
2026-01-23 23:07:48 -05:00