Proxy: local abaplint messages on a bare 'save failed' (EPOD syntax check cannot see the rejected source)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,8 @@ import json
|
||||
import re
|
||||
import time
|
||||
|
||||
from . import localcheck
|
||||
|
||||
MODEL_TOOLS = {
|
||||
"sap_search_object", "sap_pull_source", "sap_object_structure", "sap_object_members",
|
||||
"sap_usage_references", "sap_element_info", "sap_inactive_objects", "sap_short_dumps",
|
||||
@@ -56,8 +58,10 @@ class BudgetExceeded(Exception):
|
||||
|
||||
|
||||
class ToolProxy:
|
||||
def __init__(self, mcp, prefix, budget, log_path, tool_schema=None):
|
||||
def __init__(self, mcp, prefix, budget, log_path, tool_schema=None, release=None):
|
||||
self.mcp = mcp
|
||||
self.release = release # task release target, for the local syntax check
|
||||
self.syntax_hints = 0 # failed writes that got local syntax messages
|
||||
self.variant = VARIANTS.get(tool_schema) if tool_schema else None
|
||||
self.started = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) # dump times are UTC
|
||||
self.prefix = prefix.upper()
|
||||
@@ -163,7 +167,12 @@ class ToolProxy:
|
||||
src = self.last_source.get(str(args.get("objectName", "")).upper())
|
||||
if src is not None:
|
||||
err, text = self._activation_fallback(dict(args, source=src), err, text)
|
||||
raw_text = text
|
||||
if tool in ("sap_push_source", "sap_push_element") and localcheck.is_bare_save_failure(text):
|
||||
text = self._add_syntax_messages(args, text)
|
||||
result = (err, self._filter(tool, text))
|
||||
if text != raw_text:
|
||||
entry["raw_result"] = raw_text
|
||||
if tool in WRITE_TOOLS:
|
||||
failed = err or '"success":false' in text.replace(" ", "")
|
||||
self.fail_streak = self.fail_streak + 1 if failed else 0
|
||||
@@ -183,6 +192,15 @@ class ToolProxy:
|
||||
self.log.flush()
|
||||
return result
|
||||
|
||||
def _add_syntax_messages(self, args, text):
|
||||
"""SAP says only "save operation failed". The EPOD syntax check reads the stored version, not the
|
||||
rejected source, so the proxy checks the rejected source with local abaplint and adds the messages."""
|
||||
msgs = localcheck.parser_messages(args.get("objectType"), args.get("objectName"), args.get("source"),
|
||||
args.get("includeType"), args.get("functionGroup"), self.release)
|
||||
if msgs:
|
||||
self.syntax_hints += 1
|
||||
return localcheck.augment(text, msgs)
|
||||
|
||||
def _activation_fallback(self, args, err, text):
|
||||
"""EPOD does not activate a second write of a PROG or FUNC (outcome notExecuted, and sap_activate
|
||||
cannot help). Write and activate the same source through ADT REST; the agent sees one normal result."""
|
||||
|
||||
Reference in New Issue
Block a user