Repository navigation
Commit b1d0fa5
fix(langchain): preserve conversation text, roles and tool history (#6275)
* fix(langchain): retain Responses text blocks
(cherry picked from commit 83702c7)
Signed-off-by: Hao Zhe <[email protected]>
* fix(langchain): preserve generic ChatMessage roles
(cherry picked from commit cecca47)
Signed-off-by: Hao Zhe <[email protected]>
* fix(langchain): restore completed tool parts that carry their input
Motivation: OpenVikingChatMessageHistory dropped a completed ToolPart that
stores call id, name, input and output in one part. The part became a
ToolMessage, and restore_openviking_messages() discarded it because no
pending call had registered its id. A session holding only that part
restored as [] (no exception).
Approach: when a completed part has a tool_id and a nonempty tool_input,
openviking_message_to_langchain() also emits the tool call on the AIMessage.
restore_openviking_messages() drops calls whose id is already active from an
earlier pending call, so no duplicate call is added. Result-only parts (no
input) keep the existing orphan handling. A stored empty tool_input ({}) is
treated as no input and is not restored.
Validation (ran in a local venv with the SDK and integration installed):
- pytest integrations/frameworks/langchain/tests/unit: 182 passed, 1 skipped.
- The new test for a combined part fails without the src change and passes
with it.
- ruff check and ruff format --check pass on src and tests.
Not run: a live OpenViking server or Hermes host; only the in-memory client.
Report: #6242
Signed-off-by: Pujitha Paladugu <[email protected]>
Assisted-by: claude-sonnet-5-5 (via Claude Code)
(cherry picked from commit b468e19)
Signed-off-by: Hao Zhe <[email protected]>
* test(langchain): keep Responses capture coverage with the adapter
Signed-off-by: Hao Zhe <[email protected]>
* fix(langchain): preserve complete tool-call restoration
Honor explicit empty tool inputs, deduplicate calls within a stored message, and finish existing call results before emitting another assistant turn. Require recorded call identity when reconstructing a completed part; leave result-only orphans unchanged.
Extend the public sync/async history contracts for combined, split, and mixed tool records without mutating stored messages.
Signed-off-by: Hao Zhe <[email protected]>
* fix(messages): retain explicit empty tool inputs in serialization
Signed-off-by: Hao Zhe <[email protected]>
* fix(langchain): align role aliases and restored tool history
Signed-off-by: Hao Zhe <[email protected]>
* fix(langchain): scope restored tool-call deduplication to user turns
Signed-off-by: Hao Zhe <[email protected]>
* fix(session): omit tool inputs removed by the active budget
Signed-off-by: Hao Zhe <[email protected]>
* fix(langchain): retain late tool results across user messages
Signed-off-by: Hao Zhe <[email protected]>
* fix(langchain): preserve repeated tool invocations
Signed-off-by: Hao Zhe <[email protected]>
---------
Signed-off-by: Hao Zhe <[email protected]>
Signed-off-by: Pujitha Paladugu <[email protected]>
Co-authored-by: ktz03 <[email protected]>
Co-authored-by: Pujitha Paladugu <[email protected]>1 parent c6d15e9 commit b1d0fa5
10 files changed
Lines changed: 572 additions & 80 deletions
File tree
- integrations/frameworks/langchain
- src/langchain_openviking
- tests/unit
- openviking
- message
- session
- sdk/python
- openviking_sdk
- tests
- tests
- session
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
818 | 820 | | |
819 | 821 | | |
820 | 822 | | |
| |||
824 | 826 | | |
825 | 827 | | |
826 | 828 | | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
827 | 847 | | |
828 | 848 | | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
836 | 855 | | |
837 | 856 | | |
838 | 857 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
99 | | - | |
| 100 | + | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
105 | | - | |
| 107 | + | |
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
| |||
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
| 121 | + | |
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
126 | | - | |
127 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
128 | 142 | | |
129 | 143 | | |
130 | 144 | | |
| |||
134 | 148 | | |
135 | 149 | | |
136 | 150 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
| |||
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
158 | | - | |
| 164 | + | |
159 | 165 | | |
160 | 166 | | |
161 | | - | |
| 167 | + | |
| 168 | + | |
162 | 169 | | |
163 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
164 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
165 | 222 | | |
166 | 223 | | |
167 | 224 | | |
168 | 225 | | |
169 | | - | |
| 226 | + | |
| 227 | + | |
170 | 228 | | |
171 | 229 | | |
172 | | - | |
| 230 | + | |
173 | 231 | | |
174 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
175 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
176 | 240 | | |
177 | 241 | | |
178 | 242 | | |
179 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
180 | 251 | | |
181 | 252 | | |
182 | 253 | | |
| |||
0 commit comments