feat: stricter liquid rendering
This commit is contained in:
@@ -63,7 +63,11 @@ module Concerns::Toolable
|
||||
private
|
||||
|
||||
def render_template(template, context)
|
||||
Liquid::Template.parse(template).render(context.deep_stringify_keys)
|
||||
liquid_template = Liquid::Template.parse(template, error_mode: :strict)
|
||||
liquid_template.render(context.deep_stringify_keys, registers: {}, strict_variables: true, strict_filters: true)
|
||||
rescue Liquid::SyntaxError, Liquid::UndefinedVariable, Liquid::UndefinedFilter => e
|
||||
Rails.logger.error("Liquid template error: #{e.message}")
|
||||
raise "Template rendering failed: #{e.message}"
|
||||
end
|
||||
|
||||
def parse_response_body(body)
|
||||
|
||||
@@ -35,7 +35,9 @@ class Captain::Tools::HttpTool < Agents::Tool
|
||||
IPAddr.new('fe80::/10') # IPv6 Link-local
|
||||
].freeze
|
||||
|
||||
MAX_RESPONSE_SIZE = 2.megabytes
|
||||
# Limit response size to prevent memory exhaustion and match LLM token limits
|
||||
# 1MB of text ≈ 250K tokens, which exceeds most LLM context windows
|
||||
MAX_RESPONSE_SIZE = 1.megabyte
|
||||
|
||||
def execute_http_request(url, body)
|
||||
uri = URI.parse(url)
|
||||
|
||||
Reference in New Issue
Block a user