chore(repl): improve system prompt#2549
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the REPL system prompt’s “foreign function docs” formatting (moving to TypeScript-style signatures + JSDoc blocks) and extends the REPL parser/tests to handle some multiline argument formatting cases.
Changes:
- Render foreign function documentation as
```tsblocks with JSDoc + TypeScript-like signatures and TypedDict type definitions. - Allow multiline formatting inside call argument lists (including
parallel(...)) and add unit tests for it. - Update dependency lock/config and refresh prompt snapshot expectations.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/repl/langchain_repl/_foreign_function_docs.py | Reworks foreign function docs rendering to JSDoc + TS-style signatures and type blocks. |
| libs/repl/langchain_repl/interpreter.py | Allows newlines inside function call argument lists. |
| libs/repl/tests/unit_tests/test_foreign_function_docs.py | Updates expected foreign function docs output to TS/JSDoc format. |
| libs/repl/tests/unit_tests/test_system_prompt.py | Updates prompt assertions to match TS/JSDoc docs. |
| libs/repl/tests/unit_tests/test_interpreter.py | Adds coverage for multiline arguments in parallel(...) and regular calls. |
| libs/repl/tests/unit_tests/test_end_to_end.py | Adjusts fake model message iterator (adds an extra “done”). |
| libs/repl/tests/unit_tests/smoke_tests/snapshots/langchain_repl_system_prompt_mixed_foreign_functions.md | Updates snapshot to the new TS/JSDoc foreign function docs section. |
| libs/repl/pyproject.toml | Adjusts uv source configuration for local deepagents usage (editable). |
| libs/repl/uv.lock | Updates lockfile entries and dependency versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _parse_arguments(self) -> list[Expression]: | ||
| args: list[Expression] = [] | ||
| self._skip_newlines() | ||
| if self._match(")"): | ||
| return args | ||
| while True: | ||
| args.append(self._parse_expression()) |
There was a problem hiding this comment.
_parse_arguments() now skips NEWLINE tokens, but other expression contexts (notably _parse_list() / _parse_dict()) still don’t. As a result, multiline literals like [ 1, 2, ] will still fail with an unexpected NEWLINE token, which is surprising once multiline call arguments are supported. Consider applying the same _skip_newlines() handling in list/dict parsing (and possibly after opening delimiters / after commas) for consistent multiline formatting support.
| def _render_jsdoc(doc: str) -> str: | ||
| """Convert a Python docstring into a compact JSDoc block.""" | ||
| lines = inspect.cleandoc(doc).splitlines() | ||
| summary: list[str] = [] | ||
| params: list[tuple[str, str]] = [] | ||
| in_args = False | ||
| for line in lines: | ||
| stripped = line.strip() | ||
| if stripped and stripped != "Args:": | ||
| return stripped | ||
| return None | ||
| if stripped == "Args:": | ||
| in_args = True | ||
| continue |
There was a problem hiding this comment.
_render_jsdoc() only treats Args: as a structured section; docstring section headers like Returns:, Raises:, Examples: will currently be appended to the rendered summary text. Consider explicitly skipping (or separately parsing) common section headers so the JSDoc block doesn’t include these raw markers and stays focused on summary + @param entries.
| ], | ||
| ), | ||
| AIMessage(content="done"), | ||
| AIMessage(content="done"), | ||
| ] |
There was a problem hiding this comment.
This test now supplies two identical AIMessage(content="done") responses. Duplicating the same message makes the test less precise and can mask unexpected extra model invocations. Prefer asserting the expected number of model calls (via model.call_history) and/or making each fake response distinct so it’s clear which call consumed which message.
improve prompt, handle some edge cases; this seems to max out our simple tool usage eval
improve prompt, handle some edge cases; this seems to max out our simple tool usage eval