new feature: Integration with kbdb Autonomous
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -52,6 +52,57 @@ class TimOutOfScopeRail(_TimPromptRail):
|
||||
class TimProactiveOfferRail(_TimPromptRail):
|
||||
code='TIM_AOFERTA'; stage='output'; prompt_builder=staticmethod(build_aoferta_prompt)
|
||||
|
||||
# Mantém a mesma semântica do AOFERTA nativo do framework: mensagens de
|
||||
# continuidade de uma transação já aberta não constituem nova oferta
|
||||
# proativa. O bypass é estritamente dirigido pelo estado transacional, sem
|
||||
# inferência textual e sem desabilitar outros guardrails de saída.
|
||||
_TRANSACTION_CONTINUATION_STATUSES = {
|
||||
'COLLECTING_PARAMETERS',
|
||||
'AWAITING_CONFIRMATION',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def _transaction_continuation_status(cls, context: dict[str, Any]) -> str | None:
|
||||
ctx = context or {}
|
||||
status = str(ctx.get('transaction_status') or '').strip().upper()
|
||||
if status in cls._TRANSACTION_CONTINUATION_STATUSES:
|
||||
return status
|
||||
|
||||
# Compatibilidade com o contexto de output do Contas e com callers que
|
||||
# expõem o estado apenas no resultado da tool. É o mesmo fallback usado
|
||||
# pelo ProactiveOfferRail nativo: mcp_results -> tool_result.
|
||||
results = ctx.get('mcp_results') or ctx.get('tool_result') or []
|
||||
if isinstance(results, dict):
|
||||
results = [results]
|
||||
for result in reversed(list(results)):
|
||||
if not isinstance(result, dict):
|
||||
continue
|
||||
result_status = str(result.get('transaction_status') or '').strip().upper()
|
||||
if result_status in cls._TRANSACTION_CONTINUATION_STATUSES:
|
||||
return result_status
|
||||
return None
|
||||
|
||||
async def evaluate(self, text: str, context: dict[str, Any]) -> RailDecision:
|
||||
continuation_status = self._transaction_continuation_status(context)
|
||||
if continuation_status:
|
||||
return RailDecision(
|
||||
code=self.code,
|
||||
allowed=True,
|
||||
reason=f'continuidade_transacional:{continuation_status}',
|
||||
sanitized_text=text,
|
||||
metadata={
|
||||
'external': True,
|
||||
'domain': 'TIM_CONTAS',
|
||||
'mechanism': 'deterministic_transaction_bypass',
|
||||
'transaction_status': continuation_status,
|
||||
'data': {
|
||||
'allowed': True,
|
||||
'reason': f'continuidade_transacional:{continuation_status}',
|
||||
},
|
||||
},
|
||||
)
|
||||
return await super().evaluate(text, context)
|
||||
|
||||
class TimPrematureActionRail(_TimPromptRail):
|
||||
code='TIM_REVPREC'; stage='output'; profile_name='grl'; prompt_builder=staticmethod(build_revprec_prompt)
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user