Repository navigation
Conversation
|
| for key, field in args_schema.model_fields.items() | ||
| } | ||
| if isinstance(args_schema, dict): | ||
| args, arg_types, arg_desc = convert_input_schema_to_tool_args(args_schema) |
There was a problem hiding this comment.
The dictionary path does not preserve the schema's required list when advertising the tool. With required: ["query"] and an optional limit without a default, format_as_litellm_function_call() advertises both arguments as required. A required property with a default is advertised as optional instead. Both cases reproduce with a real StructuredTool: query-only input works despite the advertised requirement for limit, while an empty input accepted by the advertised schema fails execution because query is missing. Preserve the explicit required list and test both cases before merging; the new test only covers defaults that happen to match requiredness.
Artifacts
- Preserved the full authored and executed StructuredTool harness locally; remote upload is blocked by the absence of an upload capability.
- Preserved the captured parent execution showing successful LangChain calls and dictionary-schema AttributeError; remote upload remains blocked.
- Preserved the captured head execution showing the nullable-schema TypeError and successful scalar control; remote upload remains blocked.
- The previously executed Python harness remains at this local path; remote upload cannot be confirmed because no upload capability is available.
- The previously executed shell capture script remains at this local path; remote upload cannot be confirmed because no upload capability is available.
- The captured parent execution records both dictionary conversion failures and source-contract checks; the observed evidence is preserved locally.
- The captured head execution records both required-field mismatches and validation and invocation results; the observed evidence is preserved locally.
There was a problem hiding this comment.
Confirmed both requiredness mismatches independently. dc14339 preserves a detached copy of the original dict schema for native advertisement and whole-argument validation. required-with-default stays required; optional-without-default stays optional; missing required and forbidden additional properties reject before ainvoke. Existing function/Pydantic schema inference stays unchanged. Regression asserts exact advertised schema and successful invocation only for valid arguments. Full corrective diff reviewed before push; remote acceptance still pending.
|
Follow-up verification at 4468587: tested the declared LangChain Core 0.3.0 floor as well as 1.6.9. Core 0.3.0 cannot construct dict-schema StructuredTool instances, so the initial new test incorrectly assumed a newer SDK feature. The test-only follow-up keeps bridge-level dict-schema coverage on all versions and retains a separate real StructuredTool execution test, skipping only the known old-SDK construction TypeError. Production code is unchanged. Results: Core 0.3.0: 42 passed / 1 explicit unsupported-feature skip; Core 1.6.9: 43 passed. Relevant pre-commit hooks passed. Python 3.12.15, no providers/models called; not full-suite or all-version verification. Full follow-up diff reviewed before push. |
|
Expanded offline regression on corrective head dc14339: after installing the repository-declared Pillow dev dependency, |
|
Fixed the docs build failure with a minimal docs-only dependency pin in 8cad034. Failure was reproducible: docs job installed pymdown-extensions 12.2 with mkdocstrings 1.0.6; Highlighter construction raised |
📝 Changes Description
Fix
dspy.Tool.from_langchain()for LangChain tools whoseargs_schemais a JSON schema dictionary.LangChain officially supports dictionary schemas. Such a tool executes normally, but DSPy called
model_json_schema()unconditionally and raisedAttributeError. This patch sends dictionary schemas through existingconvert_input_schema_to_tool_args()while preserving the Pydantic model path and its type annotations.Verification
dictmissingmodel_json_schema.pytest tests/utils/test_langchain_tool.py tests/adapters/test_tool.py -q --extra→ 42 passed.StructuredTool, native schema required fields, invalid input rejection, and no underlying call after rejection.AI assistance used for investigation, implementation, tests, and review. No live model/provider call; no full repository or cross-platform suite. Maintainer edits enabled.