mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
fix: log agent runner best-effort failures
This commit is contained in:
@@ -112,8 +112,8 @@ class AgentResourceBuilder:
|
|||||||
'model_type': getattr(model.model_entity, 'model_type', None),
|
'model_type': getattr(model.model_entity, 'model_type', None),
|
||||||
'provider': getattr(model.provider_entity, 'name', None) if hasattr(model, 'provider_entity') else None,
|
'provider': getattr(model.provider_entity, 'name', None) if hasattr(model, 'provider_entity') else None,
|
||||||
})
|
})
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
self.ap.logger.warning(f'Failed to build model resource {model_uuid}: {e}')
|
||||||
|
|
||||||
# Add fallback models if present
|
# Add fallback models if present
|
||||||
fallback_uuids = query.variables.get('_fallback_model_uuids', [])
|
fallback_uuids = query.variables.get('_fallback_model_uuids', [])
|
||||||
@@ -126,8 +126,8 @@ class AgentResourceBuilder:
|
|||||||
'model_type': model.model_entity.model_type,
|
'model_type': model.model_entity.model_type,
|
||||||
'provider': model.provider_entity.name if hasattr(model, 'provider_entity') else None,
|
'provider': model.provider_entity.name if hasattr(model, 'provider_entity') else None,
|
||||||
})
|
})
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
self.ap.logger.warning(f'Failed to build fallback model resource {fb_uuid}: {e}')
|
||||||
|
|
||||||
return models
|
return models
|
||||||
|
|
||||||
@@ -195,8 +195,8 @@ class AgentResourceBuilder:
|
|||||||
'kb_name': kb.get_name(),
|
'kb_name': kb.get_name(),
|
||||||
'kb_type': kb.knowledge_base_entity.kb_type if hasattr(kb.knowledge_base_entity, 'kb_type') else None,
|
'kb_type': kb.knowledge_base_entity.kb_type if hasattr(kb.knowledge_base_entity, 'kb_type') else None,
|
||||||
})
|
})
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
self.ap.logger.warning(f'Failed to build knowledge base resource {kb_uuid}: {e}')
|
||||||
|
|
||||||
return kb_resources
|
return kb_resources
|
||||||
|
|
||||||
@@ -209,4 +209,4 @@ class AgentResourceBuilder:
|
|||||||
return {
|
return {
|
||||||
'plugin_storage': 'plugin' in storage_perms,
|
'plugin_storage': 'plugin' in storage_perms,
|
||||||
'workspace_storage': 'workspace' in storage_perms,
|
'workspace_storage': 'workspace' in storage_perms,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ class AgentResultNormalizer:
|
|||||||
if isinstance(content, str) and len(content) > 10000:
|
if isinstance(content, str) and len(content) > 10000:
|
||||||
# Keep reasonable length
|
# Keep reasonable length
|
||||||
data['chunk'] = {'role': 'assistant', 'content': content[:10000] + '...[truncated]'}
|
data['chunk'] = {'role': 'assistant', 'content': content[:10000] + '...[truncated]'}
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
self.ap.logger.warning(f'Failed to validate runner {descriptor.id} result size: {e}')
|
||||||
|
|
||||||
# Handle each result type
|
# Handle each result type
|
||||||
data = result_dict.get('data', {})
|
data = result_dict.get('data', {})
|
||||||
@@ -181,4 +181,4 @@ class AgentResultNormalizer:
|
|||||||
msg = provider_message.Message.model_validate(message_data)
|
msg = provider_message.Message.model_validate(message_data)
|
||||||
return msg
|
return msg
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise RunnerProtocolError(descriptor.id, f'Invalid message schema: {e}')
|
raise RunnerProtocolError(descriptor.id, f'Invalid message schema: {e}')
|
||||||
|
|||||||
@@ -243,7 +243,11 @@ class TestRegistryMetadataForPipeline:
|
|||||||
# extracted config at top level.
|
# extracted config at top level.
|
||||||
assert len(stages) == 1
|
assert len(stages) == 1
|
||||||
assert stages[0]['name'] == 'plugin:alice/my-agent/custom'
|
assert stages[0]['name'] == 'plugin:alice/my-agent/custom'
|
||||||
assert stages[0]['config'] == [{'name': 'param1', 'type': 'string'}]
|
assert stages[0]['config'] == [{
|
||||||
|
'name': 'param1',
|
||||||
|
'type': 'string',
|
||||||
|
'id': 'plugin:alice/my-agent/custom.param1',
|
||||||
|
}]
|
||||||
|
|
||||||
|
|
||||||
class TestDescriptorValidation:
|
class TestDescriptorValidation:
|
||||||
|
|||||||
Reference in New Issue
Block a user