#563·LaVague

Handle action code that exceeds the max_tokens by truncating code after last full action and adding three backticks.

Author: lyie28Created Aug 9, 2024Updated Mar 22, 2026
Labelsbugenhancementhelp wantedgood first issue

If the LLM generates an action that is longer than max tokens it will be cut off and not have the final three ticks to end the yaml code, which leads to an error.

To handle this, we can:

In extractors.py:

  1. Change the DynamicExtractor get_type to return the type yaml, json, etc. not only where there is yaml , but also when there is ```yaml and at least one action - even if there is not three ending backticks

  2. In at least YamlFromMarkdownExtractor - as this is the most frequently used extractor - but logic could be applied to others as well:

Modify extract method so that if there is three opening backticks but not three ending ones - it will truncate the text after the last full action & then add three backticks, before continuing as normal to return the action text.