feat: load the env file at start-up, trim schema lookups, remove legacy samples
Start-up - Export the env file's variables for other libraries (the Cloud provider's client) into the process environment; the app's own settings and secrets are never exported, and a value already in the environment wins. - Use GOOGLE_GENAI_USE_ENTERPRISE in place of the deprecated GOOGLE_GENAI_USE_VERTEXAI. Target architect - Look each distinct resource type up once instead of once per setting: in the run of 2026-10-07 it made 39 lookups for 8 types and exhausted its budget. terraform_schema's find takes several names; budget 30 to 45. - A cut-off schema outline says so. Removed, as leftovers of the original pipeline that nothing read - terraform/ (no longer passed terraform validate), scripts/validate.sh, tests/test_package.py and the CI steps that ran on them. - The sample outputs under docs/ and requirements.yaml. - CI now pins Terraform 1.14.3, as the container image does. Plans record the case 01 run: completed at 100% in 18 minutes with no Revision, against 60 minutes and warnings before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -187,7 +187,11 @@ class TerraformRunner:
|
||||
label, root = loaded[resource_type]
|
||||
title = f"{resource_type} ({label})"
|
||||
if find:
|
||||
return ToolResult(_clip(_find_in_schema(title, root, find)))
|
||||
# Several names in one call: one answer each, and one model request.
|
||||
names = [name for name in re.split(r"[,\s]+", find) if name]
|
||||
return ToolResult(
|
||||
_clip("\n".join(_find_in_schema(title, root, name) for name in names))
|
||||
)
|
||||
node = root
|
||||
for step in [part for part in block.split(".") if part]:
|
||||
nested = node.get("block_types", {}).get(step)
|
||||
@@ -199,7 +203,13 @@ class TerraformRunner:
|
||||
)
|
||||
node = nested["block"]
|
||||
heading = f"{title}, block {block}" if block else title
|
||||
return ToolResult(_clip(_render_schema(heading, node)))
|
||||
rendered = _render_schema(heading, node)
|
||||
if len(rendered) > _MAX_OUTPUT:
|
||||
rendered = (
|
||||
rendered[:_MAX_OUTPUT]
|
||||
+ "\n[cut short: use `block` or `find` for what is missing]"
|
||||
)
|
||||
return ToolResult(rendered)
|
||||
|
||||
def _provider_labels(self) -> str:
|
||||
return (
|
||||
@@ -502,8 +512,10 @@ LOCAL_TOOLS: dict[str, tuple[str, str]] = {
|
||||
"general",
|
||||
(
|
||||
"Look up what a Terraform resource type accepts, from the provider's own "
|
||||
"schema: its arguments and blocks, one block in full with `block`, or "
|
||||
"whether an argument exists anywhere in it with `find`."
|
||||
"schema. With `resource_type` alone: every argument and block it has, "
|
||||
"which is enough to see whether a setting exists. `block` gives one "
|
||||
"block in full. `find` says where named settings sit, or that the "
|
||||
"resource type has none."
|
||||
),
|
||||
),
|
||||
}
|
||||
@@ -580,7 +592,10 @@ def local_tools(
|
||||
},
|
||||
"find": {
|
||||
"type": "string",
|
||||
"description": "An argument or block name to look for",
|
||||
"description": (
|
||||
"Argument or block names to look for; separate several "
|
||||
"with commas to check them in one call"
|
||||
),
|
||||
},
|
||||
},
|
||||
"required": ["resource_type"],
|
||||
|
||||
Reference in New Issue
Block a user