Quality Problem Traceability and Defect Analysis for Active Pharmaceutical Ingredient and Pharmaceutical Intermediate Manufacturing: Tool Calling and Plugins

Data for this category comes from registered process documents, raw material batch ledgers, DCS production control systems, weighing systems, LIMS

What data for this category looks like

Data for this category comes from registered process documents, raw material batch ledgers, DCS production control systems, weighing systems, LIMS laboratory information management systems, chromatography data systems, and QMS quality management systems. Batch production records, material balance reports, reaction and purification step records, cleaning validation records, impurity profile reports, and deviation and change documents are retained daily. Data is updated per production batch and each process step. Fields include batch number, reaction parameters, impurity content, solvent residue amount, process completion time, and no additional statistical percentages.

What constraints these characteristics impose on tool calling and plugins

Multi-source heterogeneous data sources require tool calling to adapt to interface formats of different systems, to avoid cross-system data synchronization delays. The update rhythm per batch and process step requires tool calling to bind the context of the current production batch, ensuring query scope is limited to documents and data for the corresponding batch. Complex document structures and multi-field attributes require plugins to support parsing multi-format process records and impurity profile reports, while also limiting the context length of a single call to avoid exceeding processing limits. In scenarios where knowledge bases and applications are separated across teams, the permission scope of tool calling must be clearly defined to prevent unauthorized data access.

How to set configurations

This document is written based on FastGPT v4.17.0.

Configuration ItemRecommended SettingRationale
Workflow/API tool selectionAutoAllows the model to independently choose whether to call tools, adapting to the dynamic needs of multi-step process analysis
Workflow/API function-call configurationTriggered by the current production batchEnsures tool calling only associates documents and data for the corresponding batch, avoiding cross-batch interference
Single tool call context limit800–1200 charactersMatches the single-page document length of batch production records, preventing context overflow
Tool call timeout threshold600 secondsAligns with the standard data return duration of chromatography data systems and LIMS
Knowledge base association scopeOnly current project batch documentsComplies with batch traceability management requirements for active pharmaceutical ingredient manufacturing

Three common mistakes

  • Symptom: After calling the knowledge base-associated interface, no relevant content is returned, and the log shows that documents for the target batch were not matched. Cause: Access permissions for cross-team knowledge bases are not configured, and the correct knowledge base association scope is not specified during tool calling.
  • Symptom: After importing batch production records with revision marks, tool calling fails to extract the latest process parameters and revision content. Cause: Plugins that support parsing Word revision markup are not configured, resulting in incomplete document content reading.
  • Symptom: Tool calling is not triggered in the workflow, and the model always generates responses directly. Cause: toolChoice is not configured to auto mode, or the context condition for triggering tool calling is not set.

How to confirm configurations are correct

  • Trigger a simulated batch quality problem query, check if the tool call log shows that context parameters for the corresponding batch are bound.
  • Call the document parsing plugin, upload batch production records with revision marks, confirm that the parsed results include revised process parameters and impurity information.
  • After setting toolChoice to auto mode, submit a query requiring multi-step process analysis, check if the model actively triggers tool calling.
  • Verify cross-team knowledge base access permissions: attempt to call documents from a non-current project knowledge base, confirm that the returned results comply with permission restriction scope.

The values provided are common starting points and should be measured against the reader's own samples.